JS left-right suspension couplet AD effect code _ layout and layer

Source: Internet
Author: User

JS to make Web pages around the suspension ad effects.
Reference:

Copy Code code as follows:

<script src= "Js/ad.js" type= "Text/javascript" ></script>

2. Page Call

 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
 

3, JS suspension ad code ad.js

var browser={ie6:function () {return (window. xmlhttprequest==undefined) && (activexobject!=undefined))},getwindow:function () {var myheight=0;var myWidth =0;if (typeof (window.innerwidth) = = ' number ') {Myheight=window.innerheight;mywidth=window.innerwidth}else if ( Document.documentelement) {myheight=document.documentelement.clientheight;mywidth= Document.documentelement.clientwidth}else if (document.body) {myheight=document.body.clientheight;mywidth= document.body.clientwidth}return{' height ': myheight, ' width ': mywidth}},getscroll:function () {var myheight=0;var Mywidth=0;if (typeof (Window.pageyoffset) = = ' number ') {Myheight=window.pageyoffset;mywidth=window.pagexoffset}else if (document.documentelement) {myheight=document.documentelement.scrolltop;mywidth= Document.documentelement.scrollleft}else if (document.body) {myheight=document.body.scrolltop;mywidth= document.body.scrollleft}return{' height ': myheight, ' width ': mywidth}},getdocwidth:function (D) {if (! D) var D=document;return math.max (Math.max (D.BODY.SCROLLWIDth,d.documentelement.scrollwidth), Math.max (D.body.offsetwidth,d.documentelement.offsetwidth), Math.max ( d.body.clientwidth,d.documentelement.clientwidth))},getdocheight:function (D) {if (! D) var D=document;return math.max (Math.max (d.body.scrollheight,d.documentelement.scrollheight), Math.max ( D.body.offsetheight,d.documentelement.offsetheight), Math.max (D.body.clientheight, d.documentelement.clientheight))}};var dom={id:function (id) {var type=typeof (ID); if (type== ' object ') return Id;if ( type== ' string ') return document.getElementById (ID), return null},inserthtml:function (HTML) {var frag= Document.createdocumentfragment (); var div=document.createelement ("div");d Iv.innerhtml=html;for (Var i=0,ii= div.childnodes.length;i<ii;i++) {frag.appendchild (div.childnodes[i])}document.body.insertbefore (Frag, Document.body.firstChild)}};var myevent={add:function (Element,type,handler) {var ele=dom.id (element); if (!ele) Return;if (Ele.addeventlistener) Ele.addeventlistener (type,handler,false); else if (ele.attachevent) Ele.attachEvent (' on ' +type,handler); else ele["on" +type]=handler},remove:function (Element,type,handler) {var ele=dom.id ( Element); if (!ele) return;if (Ele.removeeventlistener) Ele.removeeventlistener (type,handler,false); else if ( ele.detachevent) ele.detachevent ("on" +type,handler); else ele[' on ' +type]=null}};var position={rightcenter:function (ID) {var id=dom.id (id); var ie6=browser.ie6 (); var win=browser.getwindow (); var ele={' height ': id.clientheight, ' width ': Id.clientwidth};if (IE6) {var scrollbar=browser.getscroll ()}else{var scrollbar={' height ': 0, ' width ': 0}; id.style.position= ' fixed '}ele.top=parseint ((win.height-ele.height)/2+scrollbar.height); Id.style.top=ele.top+ ' PX '; id.style.right= ' 3px '},floatrightcenter:function (ID) {position.rightcenter (id); var fun=function () { Position.rightcenter (ID)};if (browser.ie6 ()) {Myevent.add (window, ' scroll ', fun); Myevent.add (window, ' resize ', Fun)} Else{myevent.add (window, ' resize ', fun)}},leftcenter:function (id) {var id=dom.id (id); var ie6=browser.ie6 (); var win= Browser.getwindow (); var ele={' HeIght ': id.clientheight, ' width ': id.clientwidth};if (IE6) {var scrollbar=browser.getscroll ()}else{var scrollbar={' Height ': 0, ' width ': 0};id.style.position= ' fixed '}ele.top=parseint ((win.height-ele.height)/2+scrollbar.height); id.style.top=ele.top+ ' px '; id.style.left= ' 3px '},floatleftcenter:function (ID) {position.leftcenter (id); var fun= function () {position.leftcenter (ID)};if (browser.ie6 ()) {Myevent.add (window, ' scroll ', fun); Myevent.add (window, '
Resize ', fun)}else{myevent.add (window, ' resize ', Fun)}};
  function Ad_left () {var html; html = ' <div id= ' ad_left ' style= ' position:absolute;width:130px;height:300px;z-index:10001 ' ><a style= ' position:absolute;top:-15px;left:0 "href=" javascript:void (0); "onclick=" document.getElementById (\ ' ad_left\ '). Style.display=\ ' none\ ' "> Close </a><a href=" http://www.plchome.org "></a></div>";
dom.inserthtml (HTML);p osition.floatleftcenter (' ad_left ');
  function Ad_right () {var html; Html = ' <div id= ' ad_right "style=" position:absolute;width:130px;height:300px;z-index:10001 "><a style=" position:absolute;top:-15px;right:0 "href=" javascript:void (0); "onclick=" document.getElementById (\ ' ad_right\ '). Style.display=\ ' none\ ' "> Close </a><a href=" http://www.jb51.net "></a></div>";
dom.inserthtml (HTML);p osition.floatrightcenter (' ad_right ');
} myevent.add (window, ' Load ', ad_left); Myevent.add (window, ' Load ', ad_right);

Complete.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.