Forum Moderators: open

Message Too Old, No Replies

Javascript and Frames

Dynamic Frames With JavaScript

         

DunnoWhatNameToUse

3:11 pm on May 16, 2005 (gmt 0)



Hi All,

I need some help with changing content in one frame by clicking on a button in another frame.

Lets say I have two frames in a frame set; left and right. left has a link that triggers some jscript to modify the content in right. As I understand one must use code similair to below, BUT this does not work. Also AND unfortunately it must work in NS4.

-------------------------------

top.frames[right].document.layers['divInrightFrame'].document.open();

top.frames[right].document.layers['divInrightFrame'].document.write("new content");

top.frames[right].document.layers['divInrightFrame'].document.close();
--------------------------------

So all its supposed to do is to change the text in my div within the right frame to something else.

Please Help.
Thanks

natty

1:28 pm on May 17, 2005 (gmt 0)

10+ Year Member



hi there,

welcome to webmasterworld..

i havent taken much of a lok at this , but you seem to be adressing the name of the frame you are referencing in the top.frames[name]... without quotes.. which never helps.. should be top.frames["framename"].document.etc.etc.blah

i would always advise to download FF and take a look at the javascript console when things dont work, i find it a little more helpful than IEs little error trianlge in the corner..

btw there are loads of nice frame examples all over the place..

gl

Bernard Marx

3:27 pm on May 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"unfortunately it must work in NS4."

That is indeed unfortunate.

natty's point about quoting is true
- unless, that is, right is a variable that holds the name as a string.

That code should work for NS4 (touching wood), as long as it's called after the page has fully loaded. It wont, of course, work anywhere else. You have the up-to-date code, I presume?