Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1343 How can I show/hide a layer in a separate frame?

irt.org | Knowledge Base | JavaScript | Frame | Q1343 [ previous next ]

Q1343 How can I show/hide a layer in a separate frame?

First the frameset:

<html> <frameset rows="50%,*"> <frame src="test.htm"> <frame name="otherFrameName" src="test1.htm"> </frameset> </html>

Then test.htm:

<script language="JavaScript"><!--
function show(w,object) {
    if (w.document.layers && w.document.layers[object] != null)
        w.document.layers[object].visibility = 'visible';
    else if (document.all)
        w.document.all[object].style.visibility = 'visible';
}
function hide(w,object) {
    if (w.document.layers && w.document.layers[object] != null)
        w.document.layers[object].visibility = 'hidden';
    else if (document.all)
        w.document.all[object].style.visibility = 'hidden';
} 
//--></script>

<form>
<input type="button" value="show" onClick="show(parent.otherFrameName,'myLayer')">
<input type="button" value="hide" onClick="hide(parent.otherFrameName,'myLayer')">
</form>

Then test1.htm:

<style type="text/css"><!--
.myStyle {
    position: absolute;
    visibility: hidden;
}
//--></style>

<div class="myStyle" id="myLayer">
This is a layer
</div>

Feedback on 'Q1343 How can I show/hide a layer in a separate frame?'

What's New

How to do the impossible with Google Gears

Out and About


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.