js 异步加载不执行问题,麻烦高手解答,谢谢! js 异步浏览器插件漂浮广告 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的JS文件里放的是HTML代码,能跑起来才怪了。 <!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style type="text/css">html,body { width: 100%; height: 100%; margin: 0px; }#fd { position: fixed; height: 100px; width: 140px; background:#ff3300; }</style></head><body><div id="fd"></div><script type="text/javascript">(function (){ var div = document.getElementById("fd"); var xp = 0, yp = 0; var rx = 1, ry = 1; var delay = 13; var stop = false; function move() { if (stop) return; var width = document.body.offsetWidth - div.offsetWidth; var height = document.body.offsetHeight - div.offsetHeight; div.style.left = xp+"px"; div.style.top = yp+"px"; xp += rx; yp += ry; if (xp<=0 || xp>=width) rx = -rx; if (yp<=0 || yp>=height) ry = -ry; } setInterval(move,delay); div.onmouseover = function(){stop = true}; div.onmouseout = function(){stop = false};}());</script></body></html> 我找了个在页面右下角浮动代码可以,但是不会改为页面上方移动漂浮,代码如下,麻烦高手帮忙改下,谢谢!function getDomById_jhs(id) { return document.getElementById(id);}function setDomStyle_jhs(dom, style) { for (var i in style) { dom.style[i] = style[i]; } return dom;}function waitPageReady_jhs(fun) { if (document.readyState != 'complete') {//判断页面是否加载完成。 setTimeout(function () { window.waitPageReady_jhs(fun); }, 50); return false; } else { fun(); }}waitPageReady_jhs(function () { var rb_jhs = document.createElement('div'); rb_jhs.setAttribute('id', 'rightBottomJHS'); document.body.appendChild(rb_jhs); rb_jhs = getDomById_jhs('rightBottomJHS'); rb_jhs.innerHTML = '<div id="closeMyJHS"><img src="http://www.xxx.net/send/rightjs/rbimg/x1.jpg" id="closeImgJhs"/><span id="closeSpanJhs"></span></div><iframe src="http://www.xxx.net/send/ds.html" frameborder="0" border="0" scrolling="no" width="300px" height="250px"></iframe>'; setDomStyle_jhs(rb_jhs, { 'position': 'fixed', 'right': '0', 'bottom': '0', 'zIndex': '99999' }); setDomStyle_jhs(getDomById_jhs('closeMyJHS'), { 'position': 'absolute', 'top': '239px', 'right': '290', 'fontSize': '13px', 'lineHeight': '10px', 'height': '10px', 'width': '10px', 'color': '#FFF', 'cursor': 'pointer' }); setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), { 'backgroundColor': 'rgb(153,153,153)', 'display': 'block', 'styleFloat': 'right', 'cssFloat': 'right', 'width': '0px', 'marginRight': '2px', 'height': '0px' }); setDomStyle_jhs(getDomById_jhs('closeImgJhs'), { 'display': 'block', 'styleFloat': 'right', 'cssFloat': 'right', 'height': '10px', 'width': '10px' }); getDomById_jhs('closeMyJHS').onmouseover = function () { setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), { 'backgroundColor': 'rgb(0,102,204)' }); getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x2.jpg'); } getDomById_jhs('closeMyJHS').onmouseout = function () { setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), { 'backgroundColor': 'rgb(153,153,153)' }); getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x.jpg'); } getDomById_jhs('closeMyJHS').onmouseleave = function () { setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), { 'backgroundColor': 'rgb(153,153,153)' }); getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x.jpg'); } getDomById_jhs('closeMyJHS').onclick = function () { getDomById_jhs('rightBottomJHS').style.display = 'none'; } var isIE = !!window.ActiveXObject;//判断浏览器是否支持ActiveX控件 var isIE6 = isIE && !window.XMLHttpRequest; if (isIE6) { setDomStyle_jhs(rb_jhs, {'position': 'absolute'}) window.invl_rb_jhs = null; window.scrol_tb_jhs = function () { clearTimeout(invl_rb_jhs); invl_rb_jhs = setTimeout(function () { var winHei = document.documentElement.clientHeight; var winWid = document.documentElement.clientWidth; var winScrolY = document.documentElement.scrollTop; var winScrolX = document.documentElement.scrollLeft; setDomStyle_jhs(getDomById_jhs('rightBottomJHS'), { 'top': (winHei - (-1) * winScrolY - myJHS_height_rb) + 'px', 'left': (winWid - (-1) * winScrolX - myJHS_width_rb) + 'px' }); }, 100); } window.attachEvent('onscroll', function () { window.scrol_tb_jhs(); }); window.attachEvent('onresize', function () { window.scrol_tb_jhs(); }); window.scrol_tb_jhs(); }}); 你所说的插件是什么意思?html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。 我想说 老是去抄代码。。 很不好。。 好歹得有个研究的心改成停靠在顶部 应该是修改setDomStyle_jhs中的top left right,bottom 等等CSS属性 你所说的插件是什么意思?html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。是浏览器插件,在用户打开任何一个网页后,浏览器插件异步加载这个漂浮的JS文件 setDomStyle_jhs 这里改过css属性,但是在下面的JS里面也要调整吧,主要是很少接触JS这块,不明白的地方太多,还望指点,谢谢 关于多项select选择.请大家帮忙 问一个关于JQUERY的问题 使用“HtmlEditor”文本编辑器,判断内容是否为空出现点小问题,请教一下。 如何通过EXCEL提交表单查询?请以"中国邮政给据邮件跟踪查询系统"为例 js 赋值 急!!跳转问题,如果是错误信息就不提交到对应的页面! 关于表格操作遇到的郁闷的问题 js的扫雷 如何表述同时按下shift+tab键? 使用npm run dev 遇到的错误问题 大家帮忙来看下这个该如何实现!!急急急!!!在线等!! jquery checkbox 全选反选代码只能执行一遍,第二次就失败
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
html,body { width: 100%; height: 100%; margin: 0px; }
#fd { position: fixed; height: 100px; width: 140px; background:#ff3300; }
</style>
</head>
<body>
<div id="fd"></div>
<script type="text/javascript">
(function (){
var div = document.getElementById("fd");
var xp = 0, yp = 0;
var rx = 1, ry = 1;
var delay = 13;
var stop = false;
function move()
{
if (stop) return;
var width = document.body.offsetWidth - div.offsetWidth;
var height = document.body.offsetHeight - div.offsetHeight;
div.style.left = xp+"px";
div.style.top = yp+"px";
xp += rx;
yp += ry;
if (xp<=0 || xp>=width)
rx = -rx;
if (yp<=0 || yp>=height)
ry = -ry;
}
setInterval(move,delay);
div.onmouseover = function(){stop = true};
div.onmouseout = function(){stop = false};
}());
</script>
</body>
</html>
function getDomById_jhs(id) {
return document.getElementById(id);
}function setDomStyle_jhs(dom, style) {
for (var i in style) {
dom.style[i] = style[i];
}
return dom;
}function waitPageReady_jhs(fun) {
if (document.readyState != 'complete') {//判断页面是否加载完成。
setTimeout(function () {
window.waitPageReady_jhs(fun);
}, 50);
return false;
} else {
fun();
}
}
waitPageReady_jhs(function () {
var rb_jhs = document.createElement('div');
rb_jhs.setAttribute('id', 'rightBottomJHS');
document.body.appendChild(rb_jhs);
rb_jhs = getDomById_jhs('rightBottomJHS');
rb_jhs.innerHTML = '<div id="closeMyJHS"><img src="http://www.xxx.net/send/rightjs/rbimg/x1.jpg" id="closeImgJhs"/><span id="closeSpanJhs"></span></div><iframe src="http://www.xxx.net/send/ds.html" frameborder="0" border="0" scrolling="no" width="300px" height="250px"></iframe>';
setDomStyle_jhs(rb_jhs, {
'position': 'fixed',
'right': '0',
'bottom': '0',
'zIndex': '99999'
});
setDomStyle_jhs(getDomById_jhs('closeMyJHS'), {
'position': 'absolute',
'top': '239px',
'right': '290',
'fontSize': '13px',
'lineHeight': '10px',
'height': '10px',
'width': '10px',
'color': '#FFF',
'cursor': 'pointer'
});
setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), {
'backgroundColor': 'rgb(153,153,153)',
'display': 'block',
'styleFloat': 'right',
'cssFloat': 'right',
'width': '0px',
'marginRight': '2px',
'height': '0px'
});
setDomStyle_jhs(getDomById_jhs('closeImgJhs'), {
'display': 'block',
'styleFloat': 'right',
'cssFloat': 'right',
'height': '10px',
'width': '10px'
});
getDomById_jhs('closeMyJHS').onmouseover = function () {
setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), {
'backgroundColor': 'rgb(0,102,204)'
});
getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x2.jpg');
}
getDomById_jhs('closeMyJHS').onmouseout = function () {
setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), {
'backgroundColor': 'rgb(153,153,153)'
});
getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x.jpg');
}
getDomById_jhs('closeMyJHS').onmouseleave = function () {
setDomStyle_jhs(getDomById_jhs('closeSpanJhs'), {
'backgroundColor': 'rgb(153,153,153)'
});
getDomById_jhs('closeImgJhs').setAttribute('src', 'http://www.xxx.net/send/rightjs/rbimg/x.jpg');
}
getDomById_jhs('closeMyJHS').onclick = function () {
getDomById_jhs('rightBottomJHS').style.display = 'none';
}
var isIE = !!window.ActiveXObject;//判断浏览器是否支持ActiveX控件
var isIE6 = isIE && !window.XMLHttpRequest;
if (isIE6) {
setDomStyle_jhs(rb_jhs, {'position': 'absolute'})
window.invl_rb_jhs = null;
window.scrol_tb_jhs = function () {
clearTimeout(invl_rb_jhs);
invl_rb_jhs = setTimeout(function () {
var winHei = document.documentElement.clientHeight;
var winWid = document.documentElement.clientWidth;
var winScrolY = document.documentElement.scrollTop;
var winScrolX = document.documentElement.scrollLeft;
setDomStyle_jhs(getDomById_jhs('rightBottomJHS'), {
'top': (winHei - (-1) * winScrolY - myJHS_height_rb) + 'px',
'left': (winWid - (-1) * winScrolX - myJHS_width_rb) + 'px'
});
}, 100);
} window.attachEvent('onscroll', function () {
window.scrol_tb_jhs();
});
window.attachEvent('onresize', function () {
window.scrol_tb_jhs();
});
window.scrol_tb_jhs();
}
});
html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。
好歹得有个研究的心改成停靠在顶部 应该是修改setDomStyle_jhs中的top left right,bottom 等等CSS属性
html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。
是浏览器插件,在用户打开任何一个网页后,浏览器插件异步加载这个漂浮的JS文件
setDomStyle_jhs 这里改过css属性,但是在下面的JS里面也要调整吧,主要是很少接触JS这块,不明白的地方太多,还望指点,谢谢