• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I return to a specific spot on page

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
reply
    Bookmark Topic Watch Topic
  • New Topic