Nowadays, many website advertisements are in full swing. Now I will introduce the common code usage methods for floating couplet advertisements. This effect is displayed at a resolution of 1024*768, the image can be automatically hidden at a resolution of 800*600 to avoid affecting the visitor's browsing content. What is different from the previous Code is that, when you move the mouse over an advertisement image, you can display another set advertisement image. The following code is required to achieve the effect:
Function bigshow (){
Document. All. div_250.style.visibility = 'visable ';
Document. All. div_80.style.visibility = 'den den ';
}
Function bighide (){
Document. All. div_80.style.visibility = 'visable ';
Document. All. div_250.style.visibility = 'den den ';
}
VaR ad_80 = new array (1 );
VaR ad_250 = new array (1 );
Ad_80 [0] = "<a href = http://www.dfeng.net target = _ blank> </a> ";
Ad_250 [0] = "<a href = http://www.dfeng.net target = _ blank> </a> ";
VaR imgheight;
VaR fubioleft;
Window. Screen. width> 800? Fubioleft = 15: fubioleft = 15
Document. write ('< Div id = floater_left style = "Z-INDEX: 25; left: '+ fubioleft + 'px; width: 28px; position: absolute; top: 42px; height: 22px "> ');
Ad_now = new date ();
Ad_id = ad_no1_getseconds () % 1
VaR adhead1 = "<Div id = div_80 style = 'position: absolute; width: 95px; Height: 62px; Z-index: 12' onmouseover = bigshow ();> ";
VaR adhead2 = "</div> <Div id = div_250 style = 'position: absolute; visibility: hidden; Z-index: 13; width: 80; height: 60 'onmouseout = bighide ();> ";
// Var adhead1 = "<Div id = div_80 style = 'position: absolute; width: 95px; Height: 62px; Z-index: 20 'onmouseout = '// mm_showhidelayers (/"div_250/",/"/",/"hide/") 'onmouseover = 'Mm _ showhidelayers (/"div_250 /", /"/",/"show/") '> ";
// Var adhead2 = "</div> <Div id = div_250 style = 'position: absolute; Z-index: 21; visibility: hidden; width: 80; height: 60 'onmouseover = 'Mm _ showhidelayers (/"div_250/",/"/",/"show/") 'onmouseout = 'Mm _ showhidelayers (/"div_250 /", /"/",/"hide/") '> ";
Document. Write (adhead1 + ad_80 [ad_id] + adhead2 + ad_250 [ad_id] + "</div> ");
Document. Write ("</div> ");
Self. onerror = NULL;
Currentx = currenty = 0;
Whichit = NULL;
Lastscrollx = 0; lastscrolly = 0;
NS = (document. layers )? 1: 0;
Ie = (document. All )? 1: 0;
Function HEARTBEAT (){
If (IE ){
Diffy = Document. Body. scrolltop;
Diffx = Document. Body. scrollleft ;}
If (NS ){
Diffy = self. pageyoffset; diffx = self. pagexoffset ;}
If (diffy! = Lastscrolly ){
Percent =. 5 * (diffy-lastscrolly );
If (percent> 0) percent = math. Ceil (percent );
Else percent = math. Floor (percent );
If (IE) document. All. floater_left.style.pixeltop + = percent;
If (NS) document. floater_left.top + = percent;
Lastscrolly = lastscrolly + percent;
}
If (diffx! = Lastscrollx ){
Percent =. 5 * (diffx-lastscrollx );
If (percent> 0) percent = math. Ceil (percent );
Else percent = math. Floor (percent );
If (IE) document. All. floater_left.style.pixelleft + = percent;
If (NS) document. floater_left.left + = percent;
Lastscrollx = lastscrollx + percent;
}
}
If (NS | IE) Action = Window. setinterval ("Heartbeat ()", 1); var ad_80 = new array (1 );
VaR ad_250 = new array (1 );
Ad_80 [0] = "<a href = http://www.dfeng.net target = _ blank> </a> ";
Ad_250 [0] = "<a href = http://www.dfeng.net target = _ blank> </a> ";
VaR imgheight;
VaR fubioleft;
Window. Screen. width> 800? Fubioleft = 15: fubioleft = 15
Document. write ('< Div id = floater_right style = "Z-INDEX: 25; left: '+ fubioleft + 'px; width: 28px; position: absolute; top: 42px; height: 22px "> ');
Ad_now = new date ();
Ad_id = ad_no1_getseconds () % 1
Function myload ()
{
If (navigator. appname = "Netscape ")
{
Document. div_right_80.pagex = + window. innerWidth-130;
Document. div_right_250.pagex = + window. innerWidth-300;
Mymove ();
}
Else
{
Div_right_80.style.left = Document. Body. offsetWidth-130;
Div_right_250.style.left = Document. Body. offsetWidth-300;
Mymove ();
}
}
Function mymove ()
{
If (document. NS)
{
Document. div_right_80.left = pagexoffset + window. innerWidth-130;
Document. div_right_250.left = pagexoffset + window. innerWidth-300;
SetTimeout ("mymove ();", 20)
}
Else
{
Div_right_80.style.left = Document. Body. scrollleft + document. Body. offsetWidth-145;
Div_right_250.style.left = Document. Body. scrollleft + document. Body. offsetWidth-300;
SetTimeout ("mymove ();", 20)
}
}
VaR adhead1 = "<Div id = div_right_80 style = 'position: absolute; width: 95px; Height: 60px; Z-index: 12 'onmouseover = bigshow_right ();> ";
VaR adhead2 = "</div> <Div id = div_right_250 style = 'position: absolute; visibility: hidden; Z-index: 13; width: 250; height: 250 'onmouseout = bighide_right ();> <Div align = right> ";
Document. Write (adhead1 + ad_80 [ad_id] + adhead2 + ad_250 [ad_id] + "</div> ");
Myload ()
Document. Write ("</div> ");
Self. onerror = NULL;
Currentx_right = currenty_right = 0;
Whichit_right = NULL;
Lastscrollx_right = 0; lastscrolly_right = 0;
NS = (document. layers )? 1: 0;
Ie = (document. All )? 1: 0;
Function heartbeat_right (){
If (IE ){
Diffy_right = Document. Body. scrolltop;
Diffx_right = Document. Body. scrollleft ;}
If (NS ){
Diffy_right = self. pageyoffset; diffx_right = self. pagexoffset ;}
If (diffy_right! = Lastscrolly_right ){
Percent_right =. 5 * (diffy_right-lastscrolly_right );
If (percent_right> 0) percent_right = math. Ceil (percent_right );
Else percent_right = math. Floor (percent_right );
If (IE) document. All. floater_right.style.pixeltop + = percent_right;
If (NS) document. floater_right.top + = percent_right;
Lastscrolly_right = lastscrolly_right + percent_right;
}
If (diffx_right! = Lastscrollx_right ){
Percent_right =. 5 * (diffx_right-lastscrollx_right );
If (percent_right> 0) percent_right = math. Ceil (percent_right );
Else percent_right = math. Floor (percent_right );
If (IE) document. All. floater_right.style.pixelleft + = percent_right;
If (NS) document. floater_right.left + = percent_right;
Lastscrollx_right = lastscrollx_right + percent_right;
}
}
If (NS | IE) Action = Window. setinterval ("heartbeat_right ()", 1 );
Function bigshow_right (){
Document. All. div_right_250.style.visibility = 'visable ';
Document. All. div_right_80.style.visibility = 'den den ';
}
Function bighide_right (){
Document. All. div_right_80.style.visibility = 'visable ';
Document. All. div_right_250.style.visibility = 'den den ';
} Document. Write ('');
Document. Write ('');
Document. Write ('');
Save the above Code as a JS file, and then use <SCRIPT type = "text/JavaScript" Language = "javascript1.2" src = "* on the page to achieve this effect "*. JS "> </SCRIPT>. * indicates the file name you saved! Modify the ad image address and connection address!