//alert("hello"); (function () { var ie = !!(window.attachEvent && !window.opera); var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525); var fn = []; var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); }; var d = document; d.ready = function (f) { if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false); if (fn.push(f) > 1) return; if (ie) (function () { try { d.documentElement.doScroll('left'); run(); } catch (err) { setTimeout(arguments.callee, 0); } })(); else if (wk) var t = setInterval(function () { if (/^(loaded|complete)$/.test(d.readyState)) clearInterval(t), run(); }, 0); }; })(); console.log("default--"); var elemDiv = document.createElement('div'); elemDiv.innerHTML='
\ '; adWidth = 160;//廣告寬度 //nowX = 1000;//目前位置(left) nowX = -500;//目前位置(left) nowY = 100;//目前位置(top) function fadRefresh() { offsetX = posX + document.body.scrollLeft - nowX; offsetY = posY + document.body.scrollTop - nowY; nowX += offsetX / 5; nowY += offsetY / 5; fad_style.left = nowX; fad_style.top = nowY; floatID = setTimeout('fadRefresh()', 20 );//Refresh時間 } document.ready( function(){ document.body.appendChild(elemDiv); fad_style = document.getElementById('iRFloating').style; //fad_style = elemDiv.style; console.log("$fad_style"); console.log(fad_style); //fad_style = document.getElementById('iRFloating'); function fadIni() { innerWidth = document.body.clientWidth; innerHeight = document.body.clientHeight; edge = (innerWidth-1000)/2; if( edge > adWidth ) { //posX = edge + 1000; posX = edge-60 ; } else { posX = innerWidth-adWidth; } //posY = 100; posY = 300; } function fadStart() { fadIni(); window.onresize=fadIni; fadRefresh(); offsetX = posX + document.body.scrollLeft - nowX; offsetY = posY + document.body.scrollTop - nowY; nowX += offsetX / 5; nowY += offsetY / 5; fad_style.left = nowX; fad_style.top = nowY; floatID = setTimeout('fadRefresh()', 20 );//Refresh時間 } fadStart(); } );