aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Is there a way to automatically default a webpage to a specific area upon load? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Is there a way to automatically default a webpage to a specific area upon load?" Watch "Is there a way to automatically default a webpage to a specific area upon load?" New topic
Author

Is there a way to automatically default a webpage to a specific area upon load?

Gerard Largosa
Greenhorn

Joined: Jul 11, 2006
Posts: 12
Is there a way to have the webpage automatically default to a specific line after loading? For example, I have a really long webpage, I want the webpage to default on the button, middle or top of the webpage upon refresh. Is this possible? Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

What does it mean to "default" a web page?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gerard Largosa
Greenhorn

Joined: Jul 11, 2006
Posts: 12
What I have is a long webpage(manual), on load I want to set it up to show the middle or bottom of the webpage, not the top. By default the webpage automatically shows the user the top of the webpage, I want to set the page up to show the middle or button of the page, on load/reload instead.

So I guess what I meant by "Is there a way to automatically default a webpage to a specific area upon load" means Is there a way to automatically set a webpage to display the middle or bottom on load or reload.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

If there is a specific control that you want to set focus to, you could do that in the onload handler.

Otherwise, you could add anchor tags using the name attribute and navigate to them by using #name at the end of the url.

For example, this link to an issue of the JavaRanch Journal:

http://www.javaranch.com/journal/200510/Journal200510.jsp#a1

uses that mechanism to bring you to specific article on that page.
Jason Cox
Ranch Hand

Joined: Jan 21, 2004
Posts: 287

[ September 27, 2006: Message edited by: Rob Aught ]
Gerard Largosa
Greenhorn

Joined: Jul 11, 2006
Posts: 12
Is there a way to set focus on an anchor when the page loads? I want it to automatically go to a specific anchor(middle) everytime it is loaded.
Jason Cox
Ranch Hand

Joined: Jan 21, 2004
Posts: 287
Yes. Just set the anchor label in your URL. For example to get to the middle of the page you might set the anchor tag to look like this -



However, unless you're linking from somewhere else this isn't going to happen.

The only other way would be to do an onLoad call in the body tag.



You'll have to replace "onToad" with "onLoad". Sorry, limitation of the forum.
Gerard Largosa
Greenhorn

Joined: Jul 11, 2006
Posts: 12
Thanks for the all the suggestions, it works now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a way to automatically default a webpage to a specific area upon load?