wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How do I return to a specific spot on page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How do I return to a specific spot on page" Watch "How do I return to a specific spot on page" New topic
Author

How do I return to a specific spot on page

Bruce Sparo
Greenhorn

Joined: Jun 24, 2004
Posts: 9
Hey guys,

I was hoping for some help. I'm using the html:select property to show a two drop down menus to the user.

refreshPage(this.form) is a javascript function that I have defined to do some work.

My problem is that the page itself is fairly lengthy and everytime the user clicks on the button, it returns them to the top of the page.

What can I do to force the page to return to the very spot that the user clicked the button.

[ Jess disabled smilies and converted quote tag to a code tag ]
[ July 20, 2004: Message edited by: Jessica Sant ]

If I haven't already said it... THANKS for responding.
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

I'm going to move this to the HTML/Javascript forum seeing as though this is really a JavaScript question -- and that way our resident guru, Eric can help out.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Okay,

Now I am assuming that the JavaScript functio is submitting a form since you are passing the form object to the function.

If this is the casue, you are going to have to adjust the action attribute of the form to include the anchor tag and you have to place an anchor tag on the page near the dropdown

For example the anchor tag look like: <a name="theSpot"></a>

Now you need to change the form action to include the anchor.

action="thePage.html#theSpot"

See if that helps you out any...

Eric
Bruce Sparo
Greenhorn

Joined: Jun 24, 2004
Posts: 9
Eric...

First of all thank you for responding but you solution won't help me in this situation.

I should have explained my better in my original post. You see I'm using STRUTS and in my function -

<SCRIPT>
function refreshPage(form)
{
form.action = "/tops/editAdmin.do";
form.submit();
return false;
}
</SCRIPT>

- I'm directing the action towards the action path in my strut-config.xml file; consequently, that's why I had it posted in the struts forum.

<action path="/editAdmin"
type="com.hibbertgroup.client.tops.webApp.EditAdminAction"
name="adminForm"
scope="session"
validate="false"
input="editAdmin">
<forward name="success" path="/templates/EditAdmin.jsp"/>
</action>

I should have explained it better.

Any help....
[ July 20, 2004: Message edited by: Bruce Sparo ]
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
In such situation, regardles to Struts or any other system, I do the following:

1. When form is submitted, I set current X and Y scroll position to a hidden fields in a form submitted.

2. If when page is loaded, those values exist (i.e. I am able to get them as request.getParameter()), I set an onload handler, which scrolles the page to specified position.

Let me know if you want some examples - I don't have anything right now, but I can cut/paste something from existing code tommorow.
Pedro Penna
Ranch Hand

Joined: Jun 05, 2004
Posts: 46
You can use something similar to Eric Pascarello's or Yuriy Fuksenko's solution.

Create a field in your ActionForm to store a temporary value that indicates "the spot". In your Action's code you could use the setPath method of the ActionForward object to change the response path.



Or you can use the form's temporary variable to indicate which element will receive focus after the page is loaded, using the onLoad event handler.



PS: The last script will only work if you change "on_load" to "onload".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I return to a specific spot on page