heyseuss
09-08-2004, 06:50 AM
Hi
I'm trying out having two iframes. One is a hidden CSS layer, and the second should pass a URL to the first and also send a JavaScript command to the parent frame to 'show' the hidden layer. The CSS is fine, and I can get it to work when everything is in the same frame, so no problems there. But at present when you click a link from the second iframe, I believe the link is loading in the first iframe, but the iframe is not being made visible via the JavaScript.
The JavaScript functions for turning the CSS layers on and off are currently in the parent frame.
How do I send a javascript command from one iframe into the parent?
Below is the code I'm using at present in case it is helpful.
i've got one parent page with the following code:
<html>
<head>
<SCRIPT language=javascript>
IE = (document.all) ? 1:0;
NN = (document.layers) ? 1:0;
function hideLayer(name){
if (NN) {
eval('document.'+name+'.visibility = "hidden"');
}
else if (IE){
eval('document.all.'+name+'.style.visibility = "hidden"');
}
}
function showLayer(name){
if (NN) {
eval('document.'+name+'.visibility = "visible"');
}
else if (IE){
eval('document.all.'+name+'.style.visibility = "visible"');
}
}
</SCRIPT>
</head>
<body>
<DIV ID="layer1" style="visibility:hidden;">
<iframe name="iframe2" src="iframe2.html" align="top" height="200" width="95" hspace="10" vspace="10" align="middle">
</DIV>
<p>
<iframe name="iframe1" src="iframe1.html" align="top" height="200" width="95%" hspace="10" vspace="10" align="middle">
</body>
</html>
a page called iframe1.html with the code:
<a href="image.jpg" target="iframe2" onMouseUp="showLayer('layer1')">
Click me to show</a>
and a page called iframe2.html which is the one to be hidden and made visible with the code:
This is the layer you want to hide. <a href="javascript:void(0);" onMouseUp="hideLayer('layer1')">Hide again</a>
Thanks
Luke
I'm trying out having two iframes. One is a hidden CSS layer, and the second should pass a URL to the first and also send a JavaScript command to the parent frame to 'show' the hidden layer. The CSS is fine, and I can get it to work when everything is in the same frame, so no problems there. But at present when you click a link from the second iframe, I believe the link is loading in the first iframe, but the iframe is not being made visible via the JavaScript.
The JavaScript functions for turning the CSS layers on and off are currently in the parent frame.
How do I send a javascript command from one iframe into the parent?
Below is the code I'm using at present in case it is helpful.
i've got one parent page with the following code:
<html>
<head>
<SCRIPT language=javascript>
IE = (document.all) ? 1:0;
NN = (document.layers) ? 1:0;
function hideLayer(name){
if (NN) {
eval('document.'+name+'.visibility = "hidden"');
}
else if (IE){
eval('document.all.'+name+'.style.visibility = "hidden"');
}
}
function showLayer(name){
if (NN) {
eval('document.'+name+'.visibility = "visible"');
}
else if (IE){
eval('document.all.'+name+'.style.visibility = "visible"');
}
}
</SCRIPT>
</head>
<body>
<DIV ID="layer1" style="visibility:hidden;">
<iframe name="iframe2" src="iframe2.html" align="top" height="200" width="95" hspace="10" vspace="10" align="middle">
</DIV>
<p>
<iframe name="iframe1" src="iframe1.html" align="top" height="200" width="95%" hspace="10" vspace="10" align="middle">
</body>
</html>
a page called iframe1.html with the code:
<a href="image.jpg" target="iframe2" onMouseUp="showLayer('layer1')">
Click me to show</a>
and a page called iframe2.html which is the one to be hidden and made visible with the code:
This is the layer you want to hide. <a href="javascript:void(0);" onMouseUp="hideLayer('layer1')">Hide again</a>
Thanks
Luke