Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1291 Is it possible to show/hide a layer in one frame depending on a specific page being loaded in another frame?

You are here: irt.org | FAQ | JavaScript | Frame | Q1291 [ previous next ]

Try the following:

frame.htm:

<html>
<head>
<script language="JavaScript"><!--
loaded=false;
//--></script>
</head>

<frameset rows="50%,*" onLoad="loaded=true">
<frame src="test.htm">
<frame src="test1.htm">
</frameset>

</html>

test.htm:

<style><!--
.hidden { position: relative; visibility:hidden; }
.visible { position: relative; visibility:visible; }
//--></style>

<script language="JavaScript"><!--
function resetAll() {
  set('layer1','visible');
  set('layer2','visible');
  set('layer3','visible');
  set('layer4','visible');
  set('layer5','visible');
  set('layer6','visible');
}

function set(What,Value) {
    if (document.layers && document.layers[What] != null) document.layers[What].visibility = Value;
    else if (document.all) document.all[What].style.visibility = Value;
}
//--></script>

<span name="layer1" class="visible">Layer1</span>
<span name="layer2" class="visible">Layer2</span>
<span name="layer3" class="visible">Layer3</span>
<span name="layer4" class="visible">Layer4</span>
<span name="layer5" class="visible">Layer5</span>
<span name="layer6" class="visible">Layer6</span>

test1.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer1','hidden');
    setTimeout('location.href="test2.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

test2.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer2','hidden');
    setTimeout('location.href="test3.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

test3.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer3','hidden');
    setTimeout('location.href="test4.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

test4.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer4','hidden');
    setTimeout('location.href="test5.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

test5.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer5','hidden');
    setTimeout('location.href="test6.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

test6.htm:

<script language="JavaScript"><!--
function set() {
  if (parent.loaded) {
    parent.frames[0].resetAll();
    parent.frames[0].set('layer6','hidden');
    setTimeout('location.href="test1.htm"',1000);
  }
  else setTimeout('set()',1000);
}

set();
//--></script>

Feedback on 'Q1291 Is it possible to show/hide a layer in one frame depending on a specific page being loaded in another frame?'

©2018 Martin Webb