On my page there's an iframe containing a div which I've hidden with code on the actual iframe page. I want the iframe content only to be accessible by clicking a button on the main page.
Here's the main parts of the code:
Within the iframe:
Code:
<html>
<head>
<script language="javascript">
<!--
var state = 'none';
function showhide(layer_ref) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) {
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) {
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
//-->
</script>
</head>
<body onload="showhide('div')" style="display: none;">
<div id="div" name="div">
Some Content...
</div>
</body>
</html>
And on the main page:
Code:
<html>
<head>
</head>
<body>
<div id="div1">
<iframe onload="iFrameHeight()" id="blockrandom"
name="iframe"
src="http://somewhere.com/"
width="100%"
height="500"
scrolling="auto"
align="top"
frameborder="0"
class="wrapper">
This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe>
</div>
<div id="div2">
<input type="button" value="Show/Hide Search" onclick="document.getElementById('blockrandom').contentWindow.showhide('div')">
</div>
</body>
</html>
The page hides successfully but I can't get it to show again from the button on the main page.
If there's something wrong with my code or if there was a way that the iframe page could check if it was loaded on the right page or not would be great although i'm not sure if that's possible.
Any solutions or alternatives are welcome. Thanks.
P.S. This is on Joomla CMS, I don't think it should make a difference but correct me if I'm wrong.