{"id":47681,"date":"2022-02-15T17:30:45","date_gmt":"2022-02-15T09:30:45","guid":{"rendered":"http:\/\/www.xyryd.com\/?p=47681"},"modified":"2022-02-15T17:30:45","modified_gmt":"2022-02-15T09:30:45","slug":"javascript%e4%bb%a3%e7%a0%81%e5%ae%9e%e7%8e%b0-%e9%9a%8f%e6%9c%ba%e6%bc%82%e6%b5%ae%e7%9a%84%e5%b9%bf%e5%91%8a%e5%9b%be%e7%89%87-%e4%bb%a3%e7%a0%81%e5%ae%9e%e4%be%8b","status":"publish","type":"post","link":"http:\/\/www.xyryd.com\/47681.html","title":{"rendered":"javascript\u4ee3\u7801\u5b9e\u73b0 \u968f\u673a\u6f02\u6d6e\u7684\u5e7f\u544a\u56fe\u7247 \u4ee3\u7801\u5b9e\u4f8b"},"content":{"rendered":"\n
<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n <title>js\u968f\u673a\u98d8\u52a8\u7684\u5e7f\u544a\u56fe\u7247\u4ee3\u7801<\/title>\n <\/head>\n <body> \n <div id=\"main\" style=\"position:absolute;\">\n <div style=\"text-align:right;cursor:pointer;\" id=\"close\">\u5173\u95ed<\/div>\n <a href=\"\" target=\"_blank\"><img src=\"\u56fe\u7247\u5730\u5740.jpg\" border=\"0\" width=\"214\" height=\"73\" \/><\/a>\n <\/div>\n <\/body>\n<\/html>\n<script src=\"http:\/\/libs.baidu.com\/jquery\/1.11.3\/jquery.min.js\"><\/script>\n<script>\n <!--\/\/\u516c\u5171\u811a\u672c\u6587\u4ef6 main.js<\/em>\n function addEvent(obj, evtType, func, cap) {\n cap = cap || false;\n if (obj.addEventListener) {\n obj.addEventListener(evtType, func, cap);\n return true;\n } else if (obj.attachEvent) {\n if (cap) {\n obj.setCapture();\n return true;\n } else {\n return obj.attachEvent(\"on\" + evtType, func);\n }\n } else {\n return false;\n }\n }\n function removeEvent(obj, evtType, func, cap) {\n cap = cap || false;\n if (obj.removeEventListener) {\n obj.removeEventListener(evtType, func, cap);\n return true;\n } else if (obj.detachEvent) {\n if (cap) {\n obj.releaseCapture();\n return true;\n } else {\n return obj.detachEvent(\"on\" + evtType, func);\n }\n } else {\n return false;\n }\n }\n function getPageScroll() {\n var xScroll, yScroll;\n if (self.pageXOffset) {\n xScroll = self.pageXOffset;\n } else if (document.documentElement && document.documentElement.scrollLeft) {\n xScroll = document.documentElement.scrollLeft;\n } else if (document.body) {\n xScroll = document.body.scrollLeft;\n }\n if (self.pageYOffset) {\n yScroll = self.pageYOffset;\n } else if (document.documentElement && document.documentElement.scrollTop) {\n yScroll = document.documentElement.scrollTop;\n } else if (document.body) {\n yScroll = document.body.scrollTop;\n }\n arrayPageScroll = new Array(xScroll, yScroll);\n return arrayPageScroll;\n }\n function GetPageSize() {\n var xScroll, yScroll;\n if (window.innerHeight && window.scrollMaxY) {\n xScroll = document.body.scrollWidth;\n yScroll = window.innerHeight + window.scrollMaxY;\n } else if (document.body.scrollHeight > document.body.offsetHeight) {\n xScroll = document.body.scrollWidth;\n yScroll = document.body.scrollHeight;\n } else {\n xScroll = document.body.offsetWidth;\n yScroll = document.body.offsetHeight;\n }\n var windowWidth, windowHeight;\n if (self.innerHeight) {\n windowWidth = self.innerWidth;\n windowHeight = self.innerHeight;\n } else if (document.documentElement && document.documentElement.clientHeight) {\n windowWidth = document.documentElement.clientWidth;\n windowHeight = document.documentElement.clientHeight;\n } else if (document.body) {\n windowWidth = document.body.clientWidth;\n windowHeight = document.body.clientHeight;\n }\n if (yScroll < windowHeight) {\n pageHeight = windowHeight;\n } else {\n pageHeight = yScroll;\n }\n if (xScroll < windowWidth) {\n pageWidth = windowWidth;\n } else {\n pageWidth = xScroll;\n }\n arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)\n return arrayPageSize;\n }\n\n var AdMoveConfig = new Object();\n AdMoveConfig.IsInitialized = false;\n AdMoveConfig.AdCount = 0;\n AdMoveConfig.ScrollX = 0;\n AdMoveConfig.ScrollY = 0;\n AdMoveConfig.MoveWidth = 0;\n AdMoveConfig.MoveHeight = 0;\n AdMoveConfig.Resize = function () {\n var winsize = GetPageSize();\n AdMoveConfig.MoveWidth = winsize[2];\n AdMoveConfig.MoveHeight = winsize[3];\n AdMoveConfig.Scroll();\n }\n AdMoveConfig.Scroll = function () {\n var winscroll = getPageScroll();\n AdMoveConfig.ScrollX = winscroll[0];\n AdMoveConfig.ScrollY = winscroll[1];\n }\n addEvent(window, \"resize\", AdMoveConfig.Resize);\n addEvent(window, \"scroll\", AdMoveConfig.Scroll);\n function AdMove(id, addCloseButton) {\n if (!AdMoveConfig.IsInitialized) {\n AdMoveConfig.Resize();\n AdMoveConfig.IsInitialized = true;\n }\n AdMoveConfig.AdCount++;\n var obj = document.getElementById(id);\n obj.style.position = \"absolute\";\n var W = AdMoveConfig.MoveWidth - obj.offsetWidth;\n var H = AdMoveConfig.MoveHeight - obj.offsetHeight;\n var x = W * Math.random(), y = H * Math.random();\n var rad = (Math.random() + 1) * Math.PI \/ 6;\n var kx = Math.sin(rad), ky = Math.cos(rad);\n var dirx = (Math.random() < 0.5 ? 1 : -1), diry = (Math.random() < 0.5 ? 1 : -1);\n var step = 1;\n var interval;\n if (addCloseButton) {\n var closebtn = document.createElement(\"div\");\n obj.appendChild(closebtn);\n\n closebtn.onclick = function () {\n obj.style.display = \"none\";\n clearInterval(interval);\n closebtn.onclick = null;\n obj.onmouseover = null;\n obj.onmouseout = null;\n obj.MoveHandler = null;\n AdMoveConfig.AdCount--;\n if (AdMoveConfig.AdCount <= 0) {\n removeEvent(window, \"resize\", AdMoveConfig.Resize);\n removeEvent(window, \"scroll\", AdMoveConfig.Scroll);\n AdMoveConfig.Resize = null;\n AdMoveConfig.Scroll = null;\n AdMoveConfig = null;\n }\n }\n }\n obj.MoveHandler = function () {\n obj.style.left = (x + AdMoveConfig.ScrollX) + \"px\";\n obj.style.top = (y + AdMoveConfig.ScrollY) + \"px\";\n rad = (Math.random() + 1) * Math.PI \/ 6;\n W = AdMoveConfig.MoveWidth - obj.offsetWidth;\n H = AdMoveConfig.MoveHeight - obj.offsetHeight;\n x = x + step * kx * dirx;\n if (x < 0) { dirx = 1; x = 0; kx = Math.sin(rad); ky = Math.cos(rad); }\n if (x > W) { dirx = -1; x = W; kx = Math.sin(rad); ky = Math.cos(rad); }\n y = y + step * ky * diry;\n if (y < 0) { diry = 1; y = 0; kx = Math.sin(rad); ky = Math.cos(rad); }\n if (y > H) { diry = -1; y = H; kx = Math.sin(rad); ky = Math.cos(rad); }\n }\n this.SetLocation = function (vx, vy) { x = vx; y = vy; }\n this.SetDirection = function (vx, vy) { dirx = vx; diry = vy; }\n this.Run = function () {\n var delay = 10;\n interval = setInterval(obj.MoveHandler, delay);\n obj.onmouseover = function () { clearInterval(interval); }\n obj.onmouseout = function () { interval = setInterval(obj.MoveHandler, delay); }\n }\n }\n \/\/--><\/em>\n<\/script>\n<script type=\"text\/javascript\">\n $(function() {\n $(\"#close\").click(function() {\n $(\"#main\").hide();\n });\n })\n var ad1 = new AdMove(\"main\", true);\n ad1.Run();\n<\/script><\/pre>\n","protected":false},"excerpt":{"rendered":"<!DOCTYPE html> <html> <head> <met […]<\/p>\n","protected":false},"author":1,"featured_media":43419,"comment_status":"open","ping_status":"","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[47,48],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/47681"}],"collection":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/comments?post=47681"}],"version-history":[{"count":0,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/47681\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/media\/43419"}],"wp:attachment":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/media?parent=47681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/categories?post=47681"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/tags?post=47681"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}