Hi
How can I have mulitple html pages setting and getting the same global JS variable? I made this little test app to demonstrate what I need. For some reason it doesn't work. It is a page with 2 frames, split horizontally. The top frame is A. The bottom frames alternate between B and C. From frame A, I need to change between B and C, and I need to "pass" some values from A to either B or C, in order to know what elements to build in these frames. What is wrong with what I did here?
index.html:
<HTML>
<FRAMESET rows="50%,*">
<FRAME name="a_fr" src="a.html" scrolling="auto">
<FRAME name="b_fr" src="b.html" scrolling="auto">
</FRAMESET>
</HTML>
a.html:
<HTML>
<HEAD>
<SCRIPT src="g.js" type=text/javascript></SCR
IPT>
<SCRIPT type=text/javascript>
function loadPageB()
{
g = 22;
parent.frames['b_fr'].loca
tion = 'b.html';
}
function loadPageC()
{
g = 55;
parent.frames['b_fr'].loca
tion = 'c.html';
}
</SCRIPT>
</HEAD>
<body>
<A HREF="javascript:loadPageB
()">Load Page B</A> <br>
<A HREF="javascript:loadPageC
()">Load Page C</A>
</body>
</HTML>
b.html:
<HTML>
<HEAD>
<SCRIPT src="g.js" type=text/javascript></SCR
IPT>
<SCRIPT type=text/javascript>
function changeB(k)
{
var div = document.getElementById('b
_div');
div.innerHTML='';
text = document.createTextNode(k)
;
div.appendChild(text);
}
</SCRIPT>
</HEAD>
<BODY onLoad="changeB(g);">
<DIV id=b_div></DIV>
</BODY>
</HTML>
c.html:
<HTML>
<HEAD>
<SCRIPT src="g.js" type=text/javascript></SCR
IPT>
<SCRIPT type=text/javascript>
function changeC(l)
{
var div = document.getElementById('c
_div');
div.innerHTML='';
text = document.createTextNode(l)
;
div.appendChild(text);
}
</SCRIPT>
</HEAD>
<BODY onLoad="changeC(g);">
<DIV id=c_div></DIV>
</BODY>
</HTML>
g.js:
var g;
var h;
Thanks
tr5
(P.S. Zvonko, you gave me this idea to solve my Q23261947)
Start Free Trial