<div class="codetitle"> <span><a style="CURSOR: pointer" data="69781" class="copybut" id="copybut69781" onclick="doCopy('code69781')"><u>复制代</u></a></span> 代码如下:</div> <div class="codebody" id="code69781"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <BR><html xmlns="http://www.w3.org/1999/xhtml" > <BR><頭> <BR><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><title></title> <br><style type="text/css"> <br>ボディ<br>{ <br>高さ:2000px; <br>} <br>.float_mx{ <br>背景:#CCC; <br>幅:100ピクセル; <br>高さ:100ピクセル; <br>表示:なし; <br>} <br></style> <br></head> <br> <br><div class="float_mx"> <br>ここに追加内容 <br> </div> <br><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <br><script type="text/javascript"> <br>(function($) { <br>$.fn.scrollBox = function(options){ <br>vardefaultOptions = { <br>speed: 0.1, //加速 <br>time: 16, //移動速度 <br>top: 200, //默认顶部 <br>align: 'right', //浮動位置、可選択左、右 <br>mix: 0 //边距離 <br>}; options = $.extend(defaultOptions, options); <br>this.each(function(){ <br>var obj = $(this); <br>init(); <br>function init(){ <br>obj.css('表示', 'ブロック'); <br>obj.css('位置', '絶対'); <br>obj.css(options.align, options.mix); .css('top', options.top 'px'); <br>obj.css('z-index', '99'); <br>move(); <br>関数 back( ) { <br>加速度 = オプション.時間; <br>var x1 = 0; <br>var y2 = 0; <br>if (document.documentElement) { <br>x1 = document.documentElement.scrollTop || 0; <br>y1 = document.documentElement.scrollTop || .body) { <br>x2 = document.body.scrollLeft || 0; <br>} <br>var x = Math.max(x2) ; <br>var y = Math.max(y1, y2); <br>var 速度 = 加速度; <br>l: x, <br>t: y, <br>s: 速度 <br>}; <br>}; <br><br>function move(){ <br>vartip = obj; <br>var old = options.top; <br>var pos = back().t; <br>pos = pos - $(tip).Cooperative().y options.top; <br>pos = $(tip).Cooperative().y pos / 10; <br>if (pos < options.top) { <br>pos = options.top; <br>} <br>if (pos != old) { <br>tip.css('top',pos "px"); <br>} <br>古い = pos; <br>window.setTimeout(function(){move();}, options.time); <br>}; <br>}); <br>}; <br>$.fn.Coowned = function(){ <br>var E = $(this)[0]; <br>var C = E.offsetTop; <br>var B = E.offsetLeft; <br>var A = E.offsetWidth; <br>var D = E.offsetHeight; <br>while (E = E.offsetParent) { <br>C = E.offsetTop; <br>B = E.offsetLeft; <br>} <br>return { <br>x: B, <br>y: C, <br>w: A, <br>h: D <br>}; <br>}; <br>})(jQuery); <br>$('.float_mx').scrollBox(); <br></script> <br></body> <br></html> <br><br> <br> このセグメントのプロキシを個別の js ファイルに配置します。コード内の css コードは実行可能で、表示はなしです。これは、面での未ダウンロードを回避するためであり、不正な問題が表示されます。 <br><br><br><br><br>代打<br><br><br>代打以下:<div class="codebody" id="code61495"> <br>(function($) { <br>$.fn.scrollBox = function(options){ <br>var defaultOptions = { <br>speed: 0.1, //加速 <br>time: 16, //移动速度 <br>top: 200, //默认顶部 <br>align: 'right', //浮动位置,可选左、右 <br>mix: 0 //边距 <br>}; <br>var options = $.extend(defaultOptions, options); <br>this.each(function(){ <br>var obj = $(this); <br>init(); <br>function init(){ <br>obj.css('display', 'block'); <br>obj.css('position', 'absolute'); <br>obj.css(options.align, options.mix); <br>obj.css('top', options.top 'px'); <br>obj.css('z-index', '99'); <br>move(); <br>} <br>function back() { <br>acceleration = options.speed; <br>time = options.time; <br>var x1 = 0; <br>var y1 = 0; <br>var x2 = 0; <br>var y2 = 0; <br>if (document.documentElement) { <br>x1 = document.documentElement.scrollLeft || 0; <br>y1 = document.documentElement.scrollTop || 0; <br>} <br>if (document.body) { <br>x2 = document.body.scrollLeft || 0; <br>y2 = document.body.scrollTop || 0; <br>} <br>var x = Math.max(x1, x2); <br>var y = Math.max(y1, y2); <br>var speed = acceleration; <br>return { <br>l: x, <br>t: y, <br>s: speed <br>}; <br>}; <br><br>function move(){ <br>var tip = obj; <br>var old = options.top; <br>var pos = back().t; <br>pos = pos - $(tip).Coordinate().y options.top; <br>pos = $(tip).Coordinate().y pos / 10; <br>if (pos < options.top) { <br>pos = options.top; <br>} <br>if (pos != old) { <br>tip.css('top',pos "px"); <br>} <br>old = pos; <br>window.setTimeout(function(){move();}, options.time); <br>}; <br>}); <br>}; <br>$.fn.Coordinate = function(){ <br>var E = $(this)[0]; <br>var C = E.offsetTop; <br>var B = E.offsetLeft; <br>var A = E.offsetWidth; <br>var D = E.offsetHeight; <br>while (E = E.offsetParent) { <br>C = E.offsetTop; <br>B = E.offsetLeft; <br>} <br>return { <br>x: B, <br>y: C, <br>w: A, <br>h: D <br>}; <br>}; <br>})(jQuery); <br> </div>