figure containing uihtml with dynamic content loses dynamic content when resized.

조회 수: 1 (최근 30일)
It looks like the figures autoresize resets the innerHTML of a web page running inside uihtml.
After resizing the figure returns to its initial state (at start-up).
This demostrates the problem, click the button in the figure, then resize the figure.
Test.html:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of error</title>
</head>
<body>
<button onclick="TestCode()">Click for dynamic content</button>
<div id="div1">
<div/>
<script>
function TestCode() {
const para = document.createElement("h1");
const node = document.createTextNode("Some Content Here.");
para.appendChild(node);
const element = document.getElementById("div1");
element.appendChild(para);
}
</script>
</body>
</html>
function init()
uifig = uifigure("Name", "UI Window", "WindowStyle","normal",'NumberTitle','off');
uifig.Position = [500 500 1000 445];
uiView = uihtml(uifig);
uiView.Position = [10 10 980 420];
uiView.HTMLSource = "Test.html";
end

채택된 답변

Dinesh
Dinesh 2024년 2월 6일
Hi Antony.
I'm unable to reproduce this behavior in R2023a.
Figure on startup:
Figure after clicking on the button 3 times:
Figure after resizing the window:
In your case, as I understand it, the dynamic content that was added disappears when the window resizes. Please let me know if my understanding is incorrect.
  댓글 수: 1
Antony
Antony 2024년 2월 6일
You are quite right, I double checked my code, I had one extra function in my version, which contained a typo.
It turns out that, if there is a small error in the JS when uihtml is initialized, then resizing will reset the div section of the DOM.
Good to know.
Thanks very much for helping me find this.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by