By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,528 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,528 IT Pros & Developers. It's quick & easy.

Why does window.scrollBy() not work for

P: 1

I am a new html developer. I write an html script program to view a specific web site for a given URL. After a web page is loaded into the application view, i then use a scrollBy() function to automatically scroll the content of the web page. The scrollBy() function does not work after i open the URL in my application?

Here is my sample code, if somone can tell me what wrong with my sample program? Here is my html file:

Expand|Select|Wrap|Line Numbers
  1. <html> <head> <title>
  2.         Web page auto scroll Test
  3.     </title> </head> <script type="text/javascript"> 
  4.     function pageScroll() 
  5.     {    
  6.         window.scrollBy(0,1);   
  7.         scrolldelay = setTimeout('pageScrol()',20);     
  8.     }
  9. </script> <body style='background-color:#FFFFFF' onload="startTime()"> <script type="text/javascript">
  10.         var ContextWindow ="",
  11. '_main','width=100%,height=92%, position=bottom, resizable=0,scrollbars=auto,toolbar=0,status=0');
  12. pageScroll();
  13. </script> </body> </html>
Oct 5 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,390
in your onload you call:
Expand|Select|Wrap|Line Numbers
  1. onload="startTime()
but your function's name is:
Expand|Select|Wrap|Line Numbers
  1. pageScroll
the script that you call with the script tags in the body is useless in this case since it is called during parse-time of the page - not when it's loaded and ready.

and if you want to scroll the page in the opened window - then its impossible at all - since this page is obviously from another domain and you cannot access that with javascript due to security reasons - because this would be cross-site-scripting, which is considered as an attack, so browsers will not allow it. look here for it:
Oct 8 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.