We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Jump to the bottom of the page?

Arrummzen
Arrummzen asked
on
Medium Priority
1,742 Views
Last Modified: 2008-02-01
Im not a JavaScript developer, but I need a snipit of JavaScript code for a C# application I am writting that uses a HTML Rendering control.

How do I "jump" to the bottom of my page.

Thank you for your time,
Arrummzen
Comment
Watch Question

Is that what you want??

<a href="#bottom"> jump to last page </a>
.
.
.
.
. page contents..
.
.
.
<a name="bottom"> </a>

Author

Commented:
A: It must happen automaticly, no user interaction
B: The document changes dynamicly at runtime, I don't know were the bottom is...

Thank you for your time,
Arrummzen
try this.

<body onload="window.location='#bottom';">
<body onload="window.location='#bottom';">
.
.
. pagecontents.
.
.
<a name="bottom"> </a>
</body>

Author

Commented:
A: Is that a standard HTML feature?

B: I can't control the entire document, I can only control what is put inside the <body> </body> tags. Is there anyway I can put the onload= thing (whats it called?) inside the body?

C: Is it a sign that you need to get to bed when colors start to change and things become blury?

Thank you for your time,
Arrummzen
A: yes
B: Instead of onload just call the jumptoloc() function...
C: May be

<SCRIPT LANGUAGE="JavaScript">
function jumptoloc(locatn)
{
      window.location=locatn;
}
</SCRIPT>


.
.
.
.
.
.
<SCRIPT LANGUAGE="JavaScript">
jumptoloc('#bottom');
</SCRIPT>

<a name="bottom"> bottom</a>

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
scrollTo(0,document.body.scrollHeight);
CERTIFIED EXPERT

Commented:
my example ignored and it works without any anchor

Author

Commented:
<SCRIPT language=\"JavaScript\"> scrollTo(0,document.body.scrollHeight); </SCRIPT>

I get a runntime error - "An error has occured in the script on this page"

Im not relly sure what im doing, the control is being a pain. If you can tell me how to get it to work without an error occuring, I will post another question for you.

Thank you for your time,
Arrummzen

Author

Commented:
By the way, the above code is in the <body></body> tags.

Thank you for your time,
Arrummzen

Author

Commented:
And the error is : Object required.

Thank you for your time,
Arrummzen
CERTIFIED EXPERT

Commented:
this is ok, body tag needed
<body>
<script>scrollTo(0,document.body.scrollHeight);</script>
</body>


make one test. Scroll this page to the top and paste in adress bar line below and push enter:
===========
javascript:scrollTo(0,document.body.scrollHeight);

Author

Commented:
It worked. Post your solution in this question please:

https://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20945697.html

Thank you for your time,
Arrummzen
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.