How can I dynamically create the source for a frame using javascript?
-
07-07-2019 - |
Question
Suppose I have one html page with frames. The left frame is simply a list of links, which will be displayed in the right frame. Is it possible, using javascript, to generate the contents of the left frame when the page loads?
Solution
parent.frameName.document.body would be the body-element of that frame, you can either use DOM-methods ( .createElement, .appendChild, .insertBefore) or .innerHTML to populate the frame with content.
OTHER TIPS
Sure. You can use javascript's document.write()
or (as I prefer to) keep an empty container (DIV) on the left frame and inject your HTML into its innerHTML
property (also via javascript).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow