bindiya Posted December 13, 2010 Share Posted December 13, 2010 I have a javascript code window.scroll(0,1200); which used to scroll the webpage vertically onload to the middle.But now it is not working! is there any other code available(either in jquery or javascript) that help to scroll the page to the half of the page. thanks Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/ Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 Can you show the surrounding code? Most likely that's where the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146589 Share on other sites More sharing options...
bindiya Posted December 13, 2010 Author Share Posted December 13, 2010 this is my javascript code.The code in yellow is for scrolling of images,both need to be called on page load function pageScroll() { window.scrollBy(0,1000); var c=0; var s; s=setTimeout("photoGallery();",12000 ); } var c=0; var s; function photoGallery() { if (c%3==0){ document.getElementById('photo-gallery').src = "images/TIME1.gif"; } if (c%3==1){ document.getElementById('photo-gallery').src = "images/TIME2.gif"; } if (c%3==2){ document.getElementById('photo-gallery').src = "images/TIME3.gif"; } c=c+1; s=setTimeout("photoGallery();",12000 ); } </script> </head> <body onLoad="pageScroll();"> Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146590 Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 "c%3==0" ? Is this some kind of formatting error from posting, or is that actually your code? Most likely that would trigger a syntax error (check the error console, in FF it's under "Tools" > Error Console"), which would prevent the rest of the code from working. Edit: by the way the yellow wasn't a good choice. I had to highlight it to read it - use tags in future. Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146591 Share on other sites More sharing options...
bindiya Posted December 13, 2010 Author Share Posted December 13, 2010 nothing that sort ,i checked even by blocking that particular function and running only window.scrollBy(0,2000); no scrolling takes place. Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146592 Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 Is there an error? Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146593 Share on other sites More sharing options...
bindiya Posted December 13, 2010 Author Share Posted December 13, 2010 no Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146595 Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 nothing that sort ,i checked even by blocking that particular function and running only window.scrollBy(0,2000); no scrolling takes place. You say "only running window(...)" - did you bind it to the window.onload event? Could you show the code you were testing here? Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1146599 Share on other sites More sharing options...
bindiya Posted December 14, 2010 Author Share Posted December 14, 2010 <script> function pageScroll() { window.scrollBy(0,1000); </script> </head> <body onLoad="pageScroll();"> Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1147040 Share on other sites More sharing options...
Adam Posted December 14, 2010 Share Posted December 14, 2010 When I run that, the error console tells me: Error: missing } after function body Quote Link to comment https://forums.phpfreaks.com/topic/221497-code-to-scroll-the-webpage-to-the-middle-onload/#findComment-1147149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.