Solved

Jump to the bottom of the page?

Posted on 2004-04-05
15
1,369 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

861 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now