Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variable between frames

Status
Not open for further replies.

randyQ

IS-IT--Management
Apr 26, 2001
117
US
I am having trouble passing variables between frames. The variable I want to pass is the parameter in a function. For example, if I have the following function in a static frame:

<script>
function whatever(vrble)
{do this stuff}
</script>

...then I would want the &quot;vrble&quot; to be read in an onLoad command in my main frame.

Basically, I am trying to get the scrollbar color that is set when you click on a link in my static frame to carry over to all of the other pages as they are loaded. I know I can put an onLoad in all of my other pages, and reference the vrble setting from my static frame, but I can't figure out how to pull it over. Is there something I need to put in my function that will write the parameter vrble to a global varialbe? Any help is appreciated.
 
Using javascript over multiple frames in the onload can go wrong because the other frame might not be loaded yet. Allso use the same domain for both frames or it won't work.
The following function starts a function called showcontect an a frame called content and passes a variable (the value of a textarea called values).

<form id=&quot;frm&quot;>
<textarea ID=&quot;values&quot; NAME=&quot;values&quot;>Hello</textarea>
<script language=&quot;javascript&quot;>
setcontent();
function setcontent() {
try {
parent.frames.item('content').eval('showcontent(\'' + escape(String(frm.values.value)) + '\')');
}
catch(errorObject) {
setTimeout('setcontent()', 500);
}
}
</script>
 
I got it to work. I defined a variable in the frameset, so that as people load new pages, the variable stays constant. Now, when someone clicks on a link to customize the scrollbar colors, the function sets the variable in the frameset. Then, in all of the dynamic pages, they just call that variable in the onload command. Check it out:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top