Couplet | couplet Advertisement | webpage
Now a lot of website advertising to do in full swing, now I would like to introduce the common couplet floating advertising effect of the code use method, introduced this effect, in the 1024*768 resolution of the normal display, in the 800*600 resolution can automatically hide, so as not to cover the page affect visitors browsing content, Here is the code needed to implement the effect:
var delta=0.015
var collection;
function Floaters () {
this.items = [];
this.additem = function (id,x,y,content)
{
document.write (' <div id= ' +id+ ' style= ' z-index:0; position:absolute; width:80px; Height:60px;left: ' + (typeof (x) = = ' string '? Eval (x): x) + '; Top: ' + (typeof (y) = = ' string '? Eval (y): y) + ' "> ' +content+ ' </DIV> ');
var newitem = {};
newitem.object = document.getElementById (ID);
newitem.x = x;
newitem.y = y;
This.items[this.items.length] = NewItem;
}
This.play = function ()
{
collection = This.items
setinterval (' Play () ', 10);
}
}
function Play ()
{
if (screen.width<=800)
{
for (var i=0;i<collection.length;i++)
{
collection[i].object.style.display = ' none ';
}
return;
}
for (var i=0;i<collection.length;i++)
{
var followobj = collection[i].object;
var followobj_x = (typeof (collection[i].x) = = ' String ' eval (collection[i].x): collection[i].x);
var followobj_y = (typeof (collection[i].y) = = ' string '? Eval (collection[i].y): COLLECTION[I].Y) ;
if ( Followobj.offsetleft!= (document.body.scrollleft+followobj_x)) {
var dx= (document.body.scrollleft+ Followobj_x-followobj.offsetleft) *delta;
dx= (dx>0?1:-1) *math.ceil (math.abs (DX));
FOLLOWOBJ.STYLE.LEFT=FOLLOWOBJ.OFFSETLEFT+DX;
}
if ( Followobj.offsettop!= (document.body.scrolltop+followobj_y)) {
var dy= (document.body.scrolltop+ Followobj_y-followobj.offsettop) *delta;
dy= (dy>0?1:-1) *math.ceil (Math.Abs (dy));
Followobj.style.top=followobj.offsettop+dy;
}
followobj.style.display = ';
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSp }
}
var thefloaters = new Floaters ();
thefloaters.additem (' followDiv1 ', ' document.body.clientwidth-100 ', 0, ' </a><br> <a href= Advertisement link address target=_blank> thefloaters.additem (' FollowDiv2 ', 0,0, ' <br><a href= ad link Address target=_blank></a> ');
thefloaters.play ();
to save the above code as a JS file, and then use the call on the page you want to achieve this effect! Pay attention to change the advertising picture address and connection address!
Mouse sensor]
Unlike the previous code, when the mouse moved to the advertising picture can be induced to display another set of good advertising large image effect, the following is the required code to achieve the effect:
function Bigshow () {
document.all.div_250.style.visibility = ' visible ';
document.all.div_80.style.visibility = ' hidden ';
}
function Bighide () {
document.all.div_80.style.visibility = ' visible ';
document.all.div_250.style.visibility = ' hidden ';
}
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_now.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_now.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></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 = ' visible ';
document.all.div_right_80.style.visibility = ' hidden ';
}
function Bighide_right () {
document.all.div_right_80.style.visibility = ' visible ';
document.all.div_right_250.style.visibility = ' hidden ';
}document.write (");
document.write (");
document.write (");
Save the above code as a JS file, and then in the page you want to implement this effect, use the
<script type= "Text/javascript" language= "javascript1.2" src= "*.js" ></SCRIPT>
Call can be, * on behalf of your saved file name! Pay attention to change the advertising picture address and connection address!
Unlike the previous two codes, a picture button is added below the ad map to allow visitors to click on the close ad picture, and the following text box is the code needed to implement the effect:
var delta=0.015;
var collection;
Var closeb=false;
Function Floaters () {
this.items = [];
This.additem = function (id,x,y,content)
{
document.write (' <div id= ' +id+ ' style= ' z-index:10; position:absolute; width:80px; Height:60px;left: ' + (typeof (x) = = ' string '? Eval (x): x) + '; Top: ' + (typeof (y) = = ' string '? Eval (y): y) + ' "> ' +content+ ' </DIV> ');
var newitem = {};
newitem.object = document.getElementById (ID);
newitem.x = x;
newitem.y = y;
this.items[this.items.length] = newitem;
}
This.play = function ()
{
collection = This.items
setinterval (' Play () ');
}
}
function play ()
{
if (screen.width <=800 | | CLOSEB)
{
for (var i=0;i<collection.length;i++)
{
collection[i].object.style.display = ' none ';
}
return;
}
for (var i=0;i<collection.length;i++)
{
var followobj = Collection[i].object;
var followobj_x = (typeof (collection[i].x) = = ' string '? Eval (collection[i].x): Collection [i].x);
var followobj_y = (tyPeof (collection[i].y) = = ' string '? Eval (collection[i].y): COLLECTION[I].Y);
if (followobj.offsetleft!= (document.body.scrollleft+followobj_x)) {
var dx= (document.body.scrollleft+followobj_x-followobj.offsetleft) *delta;
dx= (dx>0?1:-1) *math.ceil (math.abs (DX));
FOLLOWOBJ.STYLE.LEFT=FOLLOWOBJ.OFFSETLEFT+DX;
}
if (followobj.offsettop!= (document.body.scrolltop+followobj_y)) {
var dy= (document.body.scrolltop+followobj_y-followobj.offsettop) *delta;
Dy= (dy>0?1:-1) *math.ceil (Math.Abs (dy));
Followobj.style.top=followobj.offsettop+dy;
}
FollowObj.style.display = ';
}
}
function Closebanner ()
{
Closeb=true;
Return
}
var thefloaters = new Floaters ();
//
Thefloaters.additem (' FollowDiv1 ', ' document.body.clientwidth-100 ', 0, ' <a href=http://www.dfeng.net target=_ Blank></a><br> <br> ');
Thefloaters.additem (' FollowDiv2 ', 0,0, ' <a href=http://www.dfeng.net target=_blank></a><br><br> ');
Thefloaters.play ();
To save the above code as a JS file, and then in want to achieve this effect of the page with the call can be, * on behalf of your saved file name! Pay attention to change the advertising picture address and connection address!
Floating couplet Advertising---left code
If you want to show only one side, here is the code needed to achieve the left side effect:
var ad_float_left_src = "Picture address";
var ad_float_left_url = "Address";
var ad_float_left_type = "";
Document.ns = Navigator.appname = = "Microsoft Internet Explorer"
var imgheight_close
var imgleft
Window.screen.width>800? imgheight_close=120:imgheight_close=120
Window.screen.width>800? imgleft=8:imgleft=122
function Myload ()
{
Myleft.style.top=document.body.scrolltop+document.body.offsetheigh
T-imgheight_close;
Myleft.style.left=imgleft;
Leftmove ();
}
function Leftmove ()
{
Myleft.style.top=document.body.scrolltop+document.body.offsetheigh
T-imgheight_close;
Myleft.style.left=imgleft;
SetTimeout ("Leftmove ();", 50)
}
function Mm_reloadpage (init) {//reloads the window if Nav4
Resized
if (init==true) with (navigator) {if (appname== "Netscape") &&
(parseint (appversion) ==4)) {
Document. Mm_pgw=innerwidth; Document. Mm_pgh=innerheight;
Onresize=mm_reloadpage; }}
else if (innerwidth!=document. MM_PGW | | innerheight!
=document. MM_PGH) location.reload ();
}
Mm_reloadpage (True)
function Close_float_left () {
myleft.style.visibility= ' hidden ';
}
document.write ("<div id=myleft style= ' position:
Absolute;width:80;top:300;left:5;visibility:visible;z-index:1 ' > '
+ "<style>"
+ "A.closefloat:link,a.refloat:visited {text-
Decoration:none;color: #000000; font-size:12px} "
+ "A.closefloat:active,a.refloat:hover {text-decoration:underline;color: #0000FF; font-size:12px}"
+ "</style>"
+ "<table border=0 cellpadding=0 cellspacing=0><tr><td>");
if (DOCUMENT.NS) {
if (ad_float_left_type!= "SWF")
document.write ("<a href=" "+ Ad_float_left_url +" "Target
= ' _blank ' >Height=31 border=0></a> ");
Else
document.write ("<embed src=") + ad_float_left_src + "'
Quality=high width=80 height=80 type= ' application/x-shockwave-
Flash ' id=changhongout ></EMBED> ');
document.write ("</td></tr><tr><td width=80 height=20
Align=right><a href= ' javascript:close_float_left (); void (0); '
Class=closefloat><b><font color= #ff0000 > Close </font></b></a></td></tr > "
+ "</table>"
+ "</div>");
Myload ()}
Save the above code as a *. JS file, and then in the page you want to implement this effect, use
<script src= "*.js" ></SCRIPT>
Call can be, * on behalf of your saved file name! Pay attention to change the advertising picture address and connection address! The corresponding parameters can be adjusted according to the page itself.