JS menciptakan efek khusus iklan di kiri dan kanan halaman web.
Mengutip:
Salinan kode adalah sebagai berikut:
<skrip src = "js/ad.js" type = "text/javascript"> </script>
2. Panggilan halaman
<! Doctype html public "-// w3c // dtd xhtml 1.0 transisi // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns = "http://www.w3.org/1999/xhtml" lang = "zh-cn"> <head> <meta http-equiv = "tipe konten" konten = "teks/html; charset = utf-8"/<judul> JSET membuat efek iklan kiri dan htset; halaman_www.vevb.com </iteme> <tyle> body {font-family: Arial, helvetica, sans-serif, "安体"; font-size: 12px; Tinggi: 2000px; Warna:#667382}*{padding: 0px; margin: 0px;} ul {margin: 0px; padding: 0px;} li {List-style-type: none; margin: 0px; padding: 0px;}. fl {float: left;}. fr {float: right;}. cl {clear: keduanya;}. zz {margin-tapin: right;} cl {clear: keduanya;}. zz {margin-tapin; margin-left: auto;}. tc {text-align: center;}. jiac {font-weight: bold;}. cur {cursor: pointer;} img {border: 0px;} </style> </head> <body> <script src = "js/ad.js"3. JS Kode AD yang ditangguhkan AD.js
var browser = {ie6: function () {return ((window.xmlHttpRequest == tidak terdefinisi) && (ActivexObject! = Undefined))}, getWindow: function () {var myHeight = 0; var mywidth = 0; if (typeof (window.innerwidth) == 'number') {myHeight = window.innerheight; mywidth = window.innerwidth} lain jika (document.documentelement) {myHeight = document.documentelement.clientheight; mywidth = document 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} lain jika (document.documentelement) {myheight = document.documentelement.scrolltop; mywidth = document.document.scrolltop; mywidth = document 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)) (D.Body 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 (d.documentelement type = typeOf (id); if (type == 'objek') return id; if (type == 'string') return document.getElementById (id); return null}, inerthtml: function (html) {var frag = document.createdocumentFragment (); var div = document.createelement ("div"); 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 (elemen, type, handler) {var ele = dom.id (elemen); if (! ele) return; if (ele.addeventlistener) ele.addeventlistener (type, handler, false); lain jika (ele.attachevent) ele.attachevent ("on"+handler); ele ele ["on"+type] = handler ("on" function) (else ele ["on"+type] = handler, handler}, function {ole ele ["on"+type] = handler, handler ele = dom.id (elemen); if (! ele) kembali; if (eLe.removeEventListener) ele.removeeventlistener (type, handler, false); lain jika (ele.detachevent) eLe.detachevent ("on"+type, handler); lain ele ["on"+tipe] = tull ("on"+handler); lain ele ["on"+"+{non -noul = {{{{{{{{{{" {{{{{{{{{{{{{{{" id = dom.id (id); var ie6 = browser.ie6 (); var win = browser.getWindow (); var ele = {'tinggi': id.clientheight, 'width': id.clientWidth}; if (ie6) {var scrollbar = browser.getscroll}}} {var scrollbar = browser.groLRoll () scrollbar = {'height': 0, 'width': 0}; id.style.position = 'fixed'} ele.top = parseInt ((win.height-ele.height) /2+scrollbar.h delapan); 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, 'ubahze', fun)} else {myevent.add (window, 'resize', fun)}}, leftcenter ie6 = browser.ie6 (); var win = browser.getWindow (); var ele = {'height': id.clientHeight, 'width': id.clientWidth}; if (ie6) {var scrollbar = browser.getScrol 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, 'ubahze', fun)} else {myevent.add (window, 'resize', fun)}}}; html = '<div id = "ad_left" style = "Posisi: absolute; lebar: 130px; tinggi: 300px; z-index: 10001"> <a style = "Posisi: absolute; atas: -15px; kiri: 0;" href = "javascript: void (0);" OnClick = "document.geteLementById (/'ad_left/'). style.display =/'none/'"> tutup </a> <a href = "http://www.plchome.org"> <img src = "gambar/ad.jpg"/</a> </div> '; dom.inserthtml (html); position.floatleftCenter ('ad_left');} fungsi ad_right () {var html; html = '<div id = "ad_right" style = "Posisi: absolute; lebar: 130px; tinggi: 300px; z-index: 10001"> <a style = "Posisi: absolute; atas: -15px; kanan: 0;" href = "javascript: void (0);" OnClick = "document.geteLementById (/'ad_right/'). style.display =/'none/'"> tutup </a> <a href = "// www.vevb.com"> <img src = "gambar/ad.jpg"/> </a> </div> '; dom.inserthtml (html); position.floatrightCenter ('ad_right');} myevent.add (window, 'load', ad_left); myevent.add (window, 'load', ad_right);Menyelesaikan.