Special Effect code and js special effect code
Js makes the special effect of suspended advertisements on web pages.
Reference:
Copy codeThe Code is 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 floating 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.doc umentElement. 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.doc umentElement. 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 response umentElement. clientWidth)}, getDocHeight: function (D) {if (! D) var D = document; return specify umentElement. 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"); div. 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); position. 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.bkjia.com "> </a> </div> '; dom. insertHtml (html); position. floatRightCenter ('ad _ right');} myEvent. add (window, 'load', ad_left); myEvent. add (window, 'load', ad_right );
Complete.