The short answer is - Don't waste your time!
The more complete answer is - iframes are fine if the entire application is located in a single iframe.
Overview
I placed the basic components and associated javascript in an html file.
This is the basic code to embed an html page as an iframe. Note that the width and height must be set - the defaults do not scale and, therefore, are worthless.
|
At first glance, everything worked perfectly ... until I opened a debug window. That's when I discovered that the iframe is in a separate namespace from the rest of the page. In some ways, that is actually a good thing - you simply need to specify which iframe you want to access. For example, the following worked before using iframes.
mcTemp_K_UIText = document.getElementById("mcTemp_K_UIText"); <input type="number" id="mcTemp_K_UIText" class="mcTemperature" value="233" size="5" maxlength="6" min=0> K |
|
However, this is a complete disaster - the javascript security protocols don't allow the main html page to access the contents of the iframe.
Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match. |
Debug - from iframe
<script> var mcTemperature_js_callback = parent.mcTemperature_js_callback; </script> |
mcTemperature.html:37 Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match. |
Debug - to iframe
temp_frame = document.getElementById('temp_frame').contentDocument;; |
Insolation_Calculator.html:90 Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match. |
Conclusion
From w3schools - IFrame contentDocument Property
The contentDocument property returns the Document object generated by a frame or iframe element.
This property can be used in the host window to access the Document object that belongs to a frame or iframe element. Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain. |