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

M

Matt

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!
 
D

Dominique

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
 
B

bruce

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='#thebottom'">
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
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.
 
G

Grant Wagner

bruce said:
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='#thebottom'">

<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 <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_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-developer/upgrade_2.html
 
T

Thomas 'PointedEars' Lahn

bruce said:
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='#thebottom'">

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
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
Thomas 'PointedEars' Lahn
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top