Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How do I return to a specific spot on page

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 15385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.


See if that helps you out any...

Bruce Sparo
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 -

function refreshPage(form)
form.action = "/tops/";
return false;

- 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"
<forward name="success" path="/templates/EditAdmin.jsp"/>

I should have explained it better.

Any help....
[ July 20, 2004: Message edited by: Bruce Sparo ]
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
It's feeding time! Give me the food you were going to give to this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic