...

View Full Version : how to positioning the scrollbar?



joda
11-06-2009, 12:04 AM
So, here is my question:

Is there some possibility with php to put the horizontal scroll bar of the web browser into the center if the "width" of web page are bigger then the "width" of the web browser screen?

So I don't need to scroll to right if I open the page, but the horizontal scroll bar will be positioned in the center.

That code should do the same think like I when I take the scroll bar and put it in the center position, but this should be happen when I load the page automatically.

Or how can I do that?

thanks to all . . .

oesxyl
11-06-2009, 12:11 AM
So, here is my question:

Is there some possibility with php to put the horizontal scroll bar of the web browser into the center if the "width" of web page are bigger then the "width" of the web browser screen?

So I don't need to scroll to right if I open the page, but the horizontal scroll bar will be positioned in the center.

That code should do the same think like I when I take the scroll bar and put it in the center position, but this should be happen when I load the page automatically.

Or how can I do that?

thanks to all . . .
no, php is server side. Is same thing like using html/css but generated when user ask for a page. As I said, javascript or other client side language.

best regards

Fou-Lu
11-06-2009, 01:13 AM
Moved from PHP to the Javascript forum.

oesxyl
11-06-2009, 04:30 PM
/* -*- c++ -*- */
function centerdoc(){
var off;
// Firefox/Opera/Safari but not IE
off = (document.body.clientWidth - window.innerWidth)/2 - window.pageXOffset;
window.scrollTo(off,0);
};

window.onload = centerdoc;

this will work in Firefox( tested), Opera and Safari (both not tested) but somebody else must solve the problem for IE along with some browser detect code to control the flow.

best regards

WA
11-06-2009, 07:08 PM
Closing thread, as cross posted. Please continue any discussion in the original thread: http://www.codingforums.com/showthread.php?t=181385



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum