求助javascript脚本代码,根据url条件判断,控制div层的显示
发布网友
发布时间:2022-05-15 07:31
我来回答
共3个回答
热心网友
时间:2022-05-15 09:01
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
a{
cursor:pointer;
margin-left:30px;}
div{
width:200px;
height:50px;}
</style>
<script type="text/javascript">
var no1,no2;
function init(){
no1=document.getElementById("NO1");
no2=document.getElementById("NO2");
no1.style.display="none";
no2.style.display="none";
}
function opendiv(num){
init();
document.getElementById("NO"+num).style.display="block";
}
</script>
</head>
<body onload="javascript:init()">
<div><a onclick="opendiv(1)">div1</a><a onclick="opendiv(2)">div2</a></div>
<div id="NO1">这是第一个层</div>
<div id="NO2">这是第二个层</div>
</body>
</html>
热心网友
时间:2022-05-15 10:19
在一个url下默认div1.style.display=block,div2.style.display=none;
在另一个url下默认div2.style.display=block,div1.style.display=none;
热心网友
时间:2022-05-15 11:53
function disPlay(){
var b1 = document.getElementById("box1");
var b2 = document.getElementById("box2");
if(window.location.href = ""){
b1.style.display = "none";
b2.style.display = "block"
}
else{
b1.style.display = "block";
b2.style.display = "none"
}
}