2011-07-12 10 views
0

本質的に、スクロールするiFrameであることが想定されています。これらの関数はすべて正常に動作します。しかし、(これは.aspファイルにあることに注意してください)また、ユーザーがウィンドウの上にマウスを置くと、スクロールを停止する機能が必要です。それは動作しますが、ユーザーがウィンドウの周りにマウスを置いてマウスを静止させないと、スクロールが発生し、実際にはスクロールも高速になります。助言がありますか?マウスオーバー時のスクロールウィンドウのスクロール

<html> 
    <head> 
     <link href="intranet.css" rel="stylesheet" type="text/css"> 
     <style> 
     </style> 
     <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js" type="text/javascript"></script> 
     <script type="text/javascript"> 
      var num2 = 3; 
      function getheight() { 
       console.log(num2); 
       var myWidth = 0, 
      myHeight = 0; 
       if (typeof (window.innerWidth) == 'number') { 
        //Non-IE 
        myWidth = window.innerWidth; 
        myHeight = window.innerHeight; 
       } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
        //IE 6+ in 'standards compliant mode' 
        myWidth = document.documentElement.clientWidth; 
        myHeight = document.documentElement.clientHeight; 
       } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { 
        //IE 4 compatible 
        myWidth = document.body.clientWidth; 
        myHeight = document.body.clientHeight; 
       } 
       var scrolledtonum = window.pageYOffset + myHeight + 2; 
       var heightofbody = document.body.offsetHeight; 
       if (scrolledtonum >= heightofbody) { 
        window.scroll(0, 0); 
       } 
      } 

      window.onscroll = getheight; 

      function pageScroll() { 
       num2 = 3; 
       clearTimeout(scrolldelay); 
       pageScroller(); 
      } 
      function unpageScroll() { num2 = 0; } 
      function pageScroller() { 
       window.scrollBy(0, num2); 
       scrolldelay = setTimeout('pageScroller()', num); 
      } 
      var num = 50; 
      window.onmouseout = pageScroll; 
      window.onmouseover = unpageScroll; 
     </script> 
    </head> 
    <body onLoad="pageScroller()"> 
    <p></p> 
    <br /> 
    <p></p> 
    <br /> 
    <div id="datacontainer" style="position:relative;width:100%;text-align:center;" onMouseover="unpageScroll" onMouseout="unpageScroll"> 

    <!-- ADD YOUR SCROLLER COMMENT INSIDE HERE---------------------> 
    <font face="Arial, Helvetica, sans-serif" size="1"> 
    <br> 
    <center> 
    <font size=2> 
<!-- CONTENT--> 
<!-- Closing tags ---> 

答えて

0

この簡単なスクリプトは、おそらく、あなたのスクリプトを変更する方法をそこから推測することができ、動作しているようです:http://jsfiddle.net/xkuZF/1/

function func() { 
    document.body.scrollTop++; 
} 

document.body.onmouseover = function() { 
    clearInterval(interval); 
}; 

document.body.onmouseout = function() { 
    interval = setInterval(func); 
}; 

var interval = setInterval(func); 
+0

私はそれを実行にエラーがあります: 'キャッチされない例外TypeErrorを:null'なのでの「ONMOUSEOUT」プロパティを設定できません - 任意のアイデア? – Guy

+0

@Guy:これは 'document.body'が' null'であることを意味します(あなたのシナリオで可能でしょうか?)。 'document.onmouseout'を使うとどうなりますか? – pimvdb

+0

はい、私はそう信じています。それはどういう意味ですか?私はiFrameでスクリプトを使用していますが、使用するコードに違いがあるのでしょうか?また、ページがASPであることに注意してください。 – Guy

関連する問題