阑尾炎什么时候手术:“层”与“刷新”。不知是否有人发现过这个问题,求教

来源:百度文库 编辑:神马品牌网 时间:2024/04/16 20:28:03
<!--
最近发现一个奇怪的问题,层的运用好像会使刷新停止。
请看下面的代码:
打开页面后若什么都不做,会发现页面在不停的刷新;一旦点击链接切换过层之后,刷新就停止了。不知何故?如何才能使刷新继续,望诸位指点
笔者在这先谢过了
-->

<HTML>
<HEAD>
<meta http-equiv="refresh" content="2"><!--设定刷新2秒一次-->
<TITLE>测试</TITLE>

<SCRIPT LANGUAGE="JAVASCRIPT" >
var currentLayer = "Layer1";

<!--该函数通过设置visibility属性来切换两个图层----------------->
function turnOn(newLayer)
{
if(currentLayer != newLayer)
{
var thisLayer = document.getElementById(newLayer);
thisLayer.style.visibility = "visible";
var oldLayer = document.getElementById(currentLayer);
oldLayer.style.visibility = "hidden";
currentLayer = newLayer;
}
}
</SCRIPT>
<!--------------------------------------------------------->
</HEAD>

<BODY>

<!--链接一:“Tab1”-->
<DIV ID="Tab1" STYLE="position:absolute; left:20px; top:40px; width:60px; height:20px; z-index:1 ">
<A HREF="javascript:turnOn('Layer1');">Layer1</A><!--点击链接,则切换图层-->
</DIV>
<!--链接二:“Tab2”-->
<DIV ID="Tab2" STYLE="position:absolute; left:80px; top:40px; width:60px; height:20px; z-index:1 ">
<A HREF="javascript:turnOn('Layer2');">Layer2</A><!--点击链接,则切换图层-->
</DIV>
<!--层:Layer1-->
<DIV ID="Layer1" STYLE="position:absolute; left:20px; top:60px; width:500px; height:800px; z-index:1;
visibility:visible; overflow:auto ">
<H1>Layer1</H1>

</DIV>
<!--层:Layer1-->
<DIV ID="Layer2" STYLE="position:absolute; left:20px; top:60px; width:500px; height:800px; z-index:1;
visibility:hidden; overflow:auto ">
<H1>Layer2</H1>
</DIV>

</BODY >
</HTML>
非常感谢xybi的帮助,找你说的改完后果然可以了。
至于为什么出现这种情况,现在我只是有点了解,
并不十分清楚,
能否再把原因解释的详细一点:)

改成
<A HREF="#" onclick="javascript:turnOn('Layer1');">Layer1</A><!--点击链接,则切换图层-->

原因是 <A HREF="javascript:turnOn('Layer2');"> 改变了网页页面属性