Click to See Complete Forum and Search --> : Variables in frames only go one-way?
jjohnstn
03-08-2003, 02:35 PM
I am attaching a ZIP file containing a page consisting of 4 frames (1A, 2A, 1B, 2B). I can pass a variable from 1A to 2B, but not from 2B to 1A.
Frame 1A should read
"testing Testing123 done"
Frame 1B should read
"testing Jerry done"
Frame 2A should read
"testing Jerry done"
Frame 2B should read
"testing Jerry done"
Now here is the problem I'm encountering....
In IE 6.0 Frame 1A reads "testing undefined done"
In Opera 5, 6 and 7 all frames read as they should
In Netscape 6 Frame 1A reads "testing undefined done"
Older versions of Netscape seem to work okay
In Mozilla 1.2.1 Frame 1A reads "testing undefined done"
In Phoenix 0.5 Frame 1A reads "testing undefined done"
Why does this basic function work in some browsers but not others, and only work between frames in on direction?
khalidali63
03-08-2003, 02:44 PM
Did u look at the code of the link I posted in one of your earlier posts???
Doubt that,Its exactly the same code that passes a variable to one frame you can use it to pass the varaible to another,just change the frame name to which you want to make changes.
I'll look at your files too..
:cool:
Cheers
Khalid
jjohnstn
03-08-2003, 02:57 PM
Originally posted by Dave Clark
No, variables are able to be referenced in a two-directional manner. These will execute correctly from any frame in your frameset -- provided a true global variable name is used in the following cases:
alert(top.frames["1A"].globalVariableName);
alert(top.frames["1B"].globalVariableName);
alert(top.frames["2A"].globalVariableName);
alert(top.frames["2B"].globalVariableName);
The following would work for a FORM field:
alert(top.frames["1A"].document.formName.fieldName.value);
alert(top.frames["1B"].document.formName.fieldName.value);
alert(top.frames["2A"].document.formName.fieldName.value);
alert(top.frames["2B"].document.formName.fieldName.value);
Dave
Changing frame1a to use
alert(top.frames["frame2B"].variableName2);
still results in an undefined in IE6, yet works in Opera 7. Something very odd here...
jjohnstn
03-08-2003, 03:08 PM
Originally posted by khalidali63
Did u look at the code of the link I posted in one of your earlier posts???
Doubt that,Its exactly the same code that passes a variable to one frame you can use it to pass the varaible to another,just change the frame name to which you want to make changes.
I'll look at your files too..
:cool:
Cheers
Khalid
Yes I reviewed your link, but since it uses forms it didn't directly apply to this problem.
What I am doing is trying to break this problem down into the simplest form, yet it is still not working. This is the 2nd day I've been working on this :(
It seems it would be so simple to pass a single Javascript variable from one child frame to another, without using forms or DIV, and having it work in most if not all javascript enabled browsers. I cannot even make this simple thing work, much frustration here....
:confused: :confused:
khalidali63
03-08-2003, 03:27 PM
OK here is the reason I think your code is not working properly.
You have at least 4 document.write statements referring framess correctly.
Now which ever document.write takes precedent is printed and the one that is not executed until the last moment can not,because in your code you have already written in the document using document.write...make any sense?
I think you will have to point to a particular section of the page for writing just using global document.write doesn't seem to be ur answer
Khalid
khalidali63
03-08-2003, 03:54 PM
Take a look, I think this is a possible work around.
Cheers
Khalid
jjohnstn
03-08-2003, 04:06 PM
Originally posted by khalidali63
Take a look, I think this is a possible work around.
Cheers
Khalid
It works, but I can't use DIV since older browsers don't support it.
khalidali63
03-08-2003, 04:16 PM
then use the setTimeout as I did and use the document.write instead of div's,that should work too
Khalid
jjohnstn
03-08-2003, 04:36 PM
Originally posted by khalidali63
then use the setTimeout as I did and use the document.write instead of div's,that should work too
Khalid
I used the setTimeout as you showed and it still generates an error and won't appear in document.write in the body (file attached)
I am starting to think this is impossible to do, sending a variable to another child frame for inclusion within page text using document.write. DIV works, but isn't supported by all browsers.
khalidali63
03-08-2003, 05:33 PM
Well here you go my friend..
Cheers
Khalid
jjohnstn
03-08-2003, 06:24 PM
Originally posted by khalidali63
Well here you go my friend..
Cheers
Khalid
Thank you very much Khalid, it would work on my PC if I changed the timeout to a higher value (I used 150). But when uploading to a server it still gave undefined value. I think it is because the frames are loading out of sequence. Do you know of a way to run function only if all frames are loaded?
Also, when the document.write is called a function the remaining HTML in the frame is overwritten. It seems it shouldn't since the function process() is called via body onLoad, which in turn calls printIt. Yet the other HTML is overwritten.
jjohnstn
03-08-2003, 08:09 PM
Khalid & Dave,
Many thanks for all your help. Finally I believe I have found a solution (files attached).
The topframe is re-loaded with each new contentframe loaded (actually this is okay, since a random photo will be loaded each time anyway). The first time the frameset is loaded, the variable is undefined, but it reloads instantly and sets it from the contentframe. I may play with it a bit more to see if I can avoid the reload the first time, but it's not a major concern at the moment.
Thanks again guys for your assistance. It's been a learning experience to say the least :)