Solved

Jump to the bottom of the page?

Posted on 2004-04-05
15
1,373 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
0
Comment
Question by:Arrummzen
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10756038
Is that what you want??

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

Author Comment

by:Arrummzen
ID: 10756047
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
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10756050
try this.

<body onload="window.location='#bottom';">
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10756061
<body onload="window.location='#bottom';">
.
.
. pagecontents.
.
.
<a name="bottom"> </a>
</body>
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 10756066
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
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10756113
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>

0
 
LVL 12

Assisted Solution

by:venkateshwarr
venkateshwarr earned 25 total points
ID: 10756147

 you can call jumptoloc from anywhere...
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 100 total points
ID: 10756959
Hi,

Actually, the location needs to have been read and interpreted before it can jump.  Therefore, the script needs to go after the html anchor -- note that the text between the '<a>' tags is optional.  

<body...>
...content...
<a name='bottom'> </a>
<script type='text/javascript'>
window.location = '#bottom';
</script>
</body>

Vinny
0
 
LVL 25

Expert Comment

by:devic
ID: 10759781
scrollTo(0,document.body.scrollHeight);
0
 
LVL 25

Expert Comment

by:devic
ID: 10769568
my example ignored and it works without any anchor
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 10769603
<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
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 10769610
By the way, the above code is in the <body></body> tags.

Thank you for your time,
Arrummzen
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 10769614
And the error is : Object required.

Thank you for your time,
Arrummzen
0
 
LVL 25

Expert Comment

by:devic
ID: 10769657
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);
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 10769705
It worked. Post your solution in this question please:

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

Thank you for your time,
Arrummzen
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 35
jQuery on Submit 4 45
what is the best Integrated development environment 2 21
formvalidation.io validate form on class click 4 18
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question