Layer development is more important in practical applications, such as floating advertising, etc. I will briefly discuss it here.
1. Display or hide the control layer
Both methods are actually controlling styles.
Method 1: Control display attributes
<script language="javascript">
function show(status)
{
("div1"). = status;
}
</script>
<div style="left:10px;top:200px;width:250;height:100;z-index:2;">
This is a layer, can you see it? Haha.
</div>
<a href=# onClick="show('block');">Show</a>
<a href=# onClick="show('none')">Close</a>
Method 2: Control visibility attributes
<script language="javascript">
function show(status)
{
("div1"). = status;
}
<div style="left:10px;top:200px;width:250;height:100;z-index:2;visibility=hideen;">
This is a layer, can you see it? Haha.
</div>
<a href=# onClick="show('visible);">Show</a>
<a href=# onClick="show('hidden')">Close</a>
If you want to control the control layer to be closed regularly, you can add:
function setTimeStart()
10 {
11 (hiddenTips,4000);
12 }^
</script>
The above code uses the setTimeout method to control the closing of the layer after 4 seconds.
2. The movement of the control layer, similar to floating advertising
It mainly moves by controlling the values of the top and left attributes in the layer style, and randomly generating different values, it looks like it is moving.
<script language="javascript">
var a=200, b=100;
var c=0.1;
var d=5;
var t=0;
function float_1()
{
var random1 = 100*();
var random2 = 100*();
var float_1 = ? .float_1.style : document.float_1;
float_1.left = (a*(t)*(t/d)+a)+random1;
float_1.top = (b*(t)+b)+random2;
t+=c;
setTimeout("float_1()", 500);
}
</script>
</head>
<body onLoad="float_1()"><div style="position:absolute;width:200;height:100;z-index:2;visibility:visible">
Let me move.
</div>
</body>
Calling it through the setTimeout method, running every few seconds, to achieve the goal of keeping movement.
1. Display or hide the control layer
Both methods are actually controlling styles.
Method 1: Control display attributes
<script language="javascript">
function show(status)
{
("div1"). = status;
}
</script>
<div style="left:10px;top:200px;width:250;height:100;z-index:2;">
This is a layer, can you see it? Haha.
</div>
<a href=# onClick="show('block');">Show</a>
<a href=# onClick="show('none')">Close</a>
Method 2: Control visibility attributes
<script language="javascript">
function show(status)
{
("div1"). = status;
}
<div style="left:10px;top:200px;width:250;height:100;z-index:2;visibility=hideen;">
This is a layer, can you see it? Haha.
</div>
<a href=# onClick="show('visible);">Show</a>
<a href=# onClick="show('hidden')">Close</a>
If you want to control the control layer to be closed regularly, you can add:
function setTimeStart()
10 {
11 (hiddenTips,4000);
12 }^
</script>
The above code uses the setTimeout method to control the closing of the layer after 4 seconds.
2. The movement of the control layer, similar to floating advertising
It mainly moves by controlling the values of the top and left attributes in the layer style, and randomly generating different values, it looks like it is moving.
<script language="javascript">
var a=200, b=100;
var c=0.1;
var d=5;
var t=0;
function float_1()
{
var random1 = 100*();
var random2 = 100*();
var float_1 = ? .float_1.style : document.float_1;
float_1.left = (a*(t)*(t/d)+a)+random1;
float_1.top = (b*(t)+b)+random2;
t+=c;
setTimeout("float_1()", 500);
}
</script>
</head>
<body onLoad="float_1()"><div style="position:absolute;width:200;height:100;z-index:2;visibility:visible">
Let me move.
</div>
</body>
Calling it through the setTimeout method, running every few seconds, to achieve the goal of keeping movement.