figure containing uihtml with dynamic content loses dynamic content when resized.
6 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Dinesh
on 6 Feb 2024
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.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!