grieve
grieve

Reputation: 13508

How can I dynamically create the source for a frame using javascript?

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?

Upvotes: 0

Views: 1282

Answers (2)

jishi
jishi

Reputation: 24634

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.

Upvotes: 1

Kon
Kon

Reputation: 27441

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).

Upvotes: 1

Related Questions