[Couplet advertisement] JS Script class _javascript Skills
Source: Internet
Author: User
//****************************************************************************************
& Author: Wah Yu
& Date: December 31, 2004
& Website: http://www.13smile.com/
& Blog:http://blog.csdn.net/bpfish
& name: [couplet ads] JS script class
& Function: Display the couplet advertisement of the page
& Method:
& Smileadver.setleftpos (10); Set the position of the left couplet to the left of the page (PX)
& Smileadver.setlefttop (150); Set the position of the left antithetical couplet at the top of the page (PX)
& Smileadver.setrightpos (10); Set the position of the right couplet to the right of the page (PX)
& Smileadver.setrighttop (150); Set the position of the right antithetical couplet from the top of the page (PX)
& Smileadver.addleftimage (link, picture address, link target, picture hint); Add a picture of the left couplet ad
& Smileadver.addrightimage (link, picture address, link target, picture hint); Add a picture of the right couplet advertisement
& Smileadver.scroll (); Show couplet ads
&
//****************************************************************************************
function Smileadver_class () {
var leftimagearray = new Array (); Save an array of ad images to the left
var rightimagearray = new Array (); Save an array of advertising pictures to the right
var Leftpos,rightpos; LeftPos = left side of the advertisement from the left column position (px) Rightpos = Right side of the advertisement from the right column position (px)
var lefttop,righttop; Lefttop = left side of the advertisement from the top sidebar position (px) Righttop = the right side of the advertisement from the top sidebar position (px)
var lastscrolly=0;
LeftPos = Rightpos = 10; Default is 10
Lefttop = Righttop = 150; Default is 150
This.setleftpos = function (value) {
if (isNaN (value)) {value = 10;} Non-digit defaults to 10
LeftPos = value;
}
This.setrightpos = function (value) {
if (isNaN (value)) {value = 10;} Non-digit defaults to 10
Rightpos = value;
}
This.setlefttop = function (value) {
if (isNaN (value)) {value = 150;} Non-digit defaults to 150
Lefttop = value;
}
This.setrighttop = function (value) {
if (isNaN (value)) {value = 150;} Non-digit defaults to 150
Righttop = value;
}
Add to the left of the picture ad addleftimage (link, picture address, link target, picture hint)
This.addleftimage = function (href,image,target,title) {
var Imagearray = Getimagearray (Href,image,target,title);
if (Imagearray!= null) {
Leftimagearray[leftimagearray.length] = Imagearray;
}
}
Add the right picture ad addrightimage (link, picture address, link target, picture hint)
This.addrightimage = function (href,image,target,title) {
var Imagearray = Getimagearray (Href,image,target,title);
if (Imagearray!= null) {
Rightimagearray[rightimagearray.length] = Imagearray;
}
}
Internal add advertising picture use, if there is no picture address, then return a null value, otherwise return an array
function Getimagearray (href,image,target,title) {
if (image = = undefined) {return null;} No picture address, no add
if (target = = Undefined | | target = = "") {target = "_blank"}; Default to _blank open mode
target = "target=\" "+ target +" \ ";
if (title = = undefined) {//advertising picture title hint
title = "";
}else{
title = "Title=\" "+ title +" "";
}
Link to www. Automatically add http://(otherwise link will link error)
if (Href.tolowercase (). substring (0,4) = = "www.") {
href = "http://"; + href;
}
if (Image.tolowercase (). substring (0,4) = = "www.") {
Image = "http://"; + image;
}
return new Array (Href,image,target,title);
}
Internal display picture banner used Showimagediv (div name, div placement direction (left,right), div placement, div layer from the top position, display picture array variable)
function Showimagediv (Div,pos,pospx,toppx,imagearray) {
var J;
document.write ("<div id=\" "+ div +" \ "style=\" "+ pos +": "+ pospx +" PX; Position:absolute; Top: "+ toppx +" px;\ ">");
for (j=0; j< Imagearray.length; j + +) {
document.write ("<a href=\" "+ imagearray[j][0] +" "" + imagearray[j][2]+ Imagearray[j][3] + "></a>");
if (J!= imagearray.length-1) {document.write ("<table border=\" 0\ "cellpadding=\" 0\ "cellspacing=\" 0\ "><tr") ><TD height=10></td></tr></table> ");}
}
document.write ("</div>");
}
Scrolling ads Couplet Pictures
This.scroll = function () {
Showimagediv ("Smilediv1", "left", Leftpos,lefttop,leftimagearray);
Showimagediv ("Smilediv2", "right", rightpos,righttop,rightimagearray);
Window.setinterval (scrollimage,1);
}
Internal use to scroll advertising pictures
function Scrollimage () {
var diffy,percent;
Diffy=document.body.scrolltop;
Percent=.1* (diffy-lastscrolly);
if (percent>0) Percent=math.ceil (percent);
else Percent=math.floor (percent);
Document.all.smilediv1.style.pixeltop+=percent;
Document.all.smilediv2.style.pixeltop+=percent;
Lastscrolly=lastscrolly+percent;
}
}
Class End////////////////////////////////////////////////////////////////
Use sample code for class////////////////////////////////////////////////
var smileadver = new Smileadver_class ();
Smileadver.setleftpos (10);
Smileadver.setrightpos (10);
Smileadver.setlefttop (150);
Smileadver.setrighttop (150);
Smileadver.addleftimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif";, "", "asdfasdf");
Smileadver.addleftimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif");
Smileadver.addleftimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif");
Smileadver.addrightimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif");
Smileadver.addrightimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif");
Smileadver.addrightimage ("http://www.138tips.com/", "http://www.88ball.com/images/138tips.gif");
Smileadver.scroll ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.