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

Go to the bottom of the page when the page is loaded

P: n/a
The html page is very long and has a button on the bottom.
How to make the browser go to the bottom of the page when the page
is loaded??

Thanks!
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Ivo

"Matt" wrote
The html page is very long and has a button on the bottom.
How to make the browser go to the bottom of the page when the page
is loaded??

Thanks!


window.scrollTo(0,1000);
works if the page is not longer than 1000 pixels.
To be sure and calculate the real height, see
<URL: http://jibbering.com/faq/#FAQ4_9 >
HTH
Ivo
Jul 23 '05 #2

P: n/a

put the following line at the end of mypage(before </body>)
<a name=bottom></A>
and launch your page
<A href="mypage.html#bottom">my page</A>
bye
--
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr

http://forums.club-internet.fr/
Jul 23 '05 #3

P: n/a
jr********@hotmail.com (Matt) wrote in message news:<ba**************************@posting.google. com>...
The html page is very long and has a button on the bottom.
How to make the browser go to the bottom of the page when the page
is loaded??

Thanks!

Near the bottom of the screen, have an item such as:
<span id="thebottom>xxx</span>
(The span can enclose almost any type of control or text, but watch
out for putting it inside a <table>, I've had problems with this one.)
Then, code the body tag something like this:
<body onload="javascript:window.location.href='#thebotto m'">
Jul 23 '05 #4

P: n/a
JRS: In article <40*********************@news.wanadoo.nl>, seen in
news:comp.lang.javascript, Ivo <no@thank.you> posted at Thu, 27 May 2004
08:43:13 :

"Matt" wrote
The html page is very long and has a button on the bottom.
How to make the browser go to the bottom of the page when the page
is loaded??

Thanks!


window.scrollTo(0,1000);
works if the page is not longer than 1000 pixels.
To be sure and calculate the real height, see
<URL: http://jibbering.com/faq/#FAQ4_9 >


For most pages, ISTM that window.scrollTo(0,9e9); should do; and
it is shorter than your suggestion. The second parameter should not be
much more than 1.7e13 for my MSIE4.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

P: n/a
bruce wrote:
jr********@hotmail.com (Matt) wrote in message news:<ba**************************@posting.google. com>...
The html page is very long and has a button on the bottom.
How to make the browser go to the bottom of the page when the page
is loaded??

Thanks!


Near the bottom of the screen, have an item such as:
<span id="thebottom>xxx</span>
(The span can enclose almost any type of control or text, but watch
out for putting it inside a <table>, I've had problems with this one.)

Then, code the body tag something like this:
<body onload="javascript:window.location.href='#thebotto m'">


<body onload="
if (window.location.replace) {
window.location.replace(window.location.href + '#thebottom');
} else {
window.location.href = window.location.href + '#thebottom';
}
">
<!-- your page here -->
<a name="thebottom"></a>

Is supported by more browsers, allows you to link directly to "someurl.html#thebottom" and if they bookmark
the resulting page, they end up at the right place on the page without client-side Javascript.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #6

P: n/a
bruce wrote:
Near the bottom of the screen, have an item such as:
<span id="thebottom>xxx</span>
(The span can enclose almost any type of control or text, but watch
out for putting it inside a <table>, I've had problems with this one.)
Then, code the body tag something like this:
<body onload="javascript:window.location.href='#thebotto m'">


This is utter nonsense, misuse of "javascript:" and misuse of J(ava)Script.
It is code I would expect from a script-kiddie. See the FAQ and numerous
postings about why it is a Bad Thing to scroll/focus without consent of the
user. And since not every UA understands IDs, and not every UA that
understands IDs do that for "span" elements, it is not going to work
everywhere, even if we assume that J(ava)Script support is present and
enabled everywhere, which is of course not the case.
PointedEars
Jul 23 '05 #7

P: n/a
JRS: In article <40**************@PointedEars.de>, seen in
news:comp.lang.javascript, Thomas 'PointedEars' Lahn
<Po*********@nurfuerspam.de> posted at Sat, 29 May 2004 15:12:06 :
bruce wrote:
Near the bottom of the screen, have an item such as:
<span id="thebottom>xxx</span>
(The span can enclose almost any type of control or text, but watch
out for putting it inside a <table>, I've had problems with this one.)
Then, code the body tag something like this:
<body onload="javascript:window.location.href='#thebotto m'">


This is utter nonsense, misuse of "javascript:" and misuse of J(ava)Script.
It is code I would expect from a script-kiddie. See the FAQ and numerous
postings about why it is a Bad Thing to scroll/focus without consent of the
user.


It would be naive to assume that the author cannot know what the user
wants.

I have just been working on js-quick.htm, in order to force it to set
the window to a particular size, to scroll to a particular position, and
to focus a particular element on loading - and to resize the window on
unloading. This particular page is written specifically for me to use;
I put it on the Web out of mere benevolence - not for others to use /in
situ/, since that wastes my bandwidth, but for others to copy and use.
They can, if they are in the target readership, easily change or remove
these actions.

The author in this case not only has the consent of the user, but is
working under the user's instructions.

In the OP's case : the design of the page is the responsibility of the
OP and his management. This includes selection of the optimum entry
point. For example, a page showing the family tree (Ahnentafel) of your
descent from, let us say, H C B Moltke, with you at the bottom, might
well be best entered at the end, in the opinion of its designers.

Similarly, forcing a particular large window size, while generally
unwise on the Web, is not inevitably so.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.