解决方案 »

  1.   

    你的JS文件里放的是HTML代码,能跑起来才怪了。
      

  2.   


    <!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>
      

  3.   

    我找了个在页面右下角浮动代码可以,但是不会改为页面上方移动漂浮,代码如下,麻烦高手帮忙改下,谢谢!
    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();
        }
    });
      

  4.   

    你所说的插件是什么意思?
    html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。
      

  5.   

    我想说   老是去抄代码。。 很不好。。  
    好歹得有个研究的心改成停靠在顶部  应该是修改setDomStyle_jhs中的top  left right,bottom 等等CSS属性  
      

  6.   

    你所说的插件是什么意思?
    html,body { width: 100%; height: 100%; margin: 0px; }这行必须要有。
    是浏览器插件,在用户打开任何一个网页后,浏览器插件异步加载这个漂浮的JS文件
      

  7.   


    setDomStyle_jhs   这里改过css属性,但是在下面的JS里面也要调整吧,主要是很少接触JS这块,不明白的地方太多,还望指点,谢谢