 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 20th, 2004, 09:44 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
return to exact location like the 'back' button
hello
i have a webpage, longPage.asp, that's about 2-3 pages long, and when a user clicks on a link in the middle of the page, say about 1.5pages down, he is directed to another page, does some crap, clicks on a button to update the info and he is redirected back to longPage.asp.
is there anyway i can return him to the location where he was viewing previously, i.e. 1.5pages down?? like what the 'back' button on our browser does.
|
|

February 20th, 2004, 11:28 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
You can use an HTML approach with hyperlinks, such as:
...
<a name="Section2"></a>
...
You don't need to put anything in the hyperlink text area for it to work. You reference this as:
<a href="longpage.asp#Section2">Back</a>
I don't know of any way using ASP, other than using ASP to dynamically create the hyperlink as above.
|
|

February 20th, 2004, 11:44 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hmm..sounds like something feasible, but wouldnt that return the user to the page which will start from the anchor?
what i hope to do is to return the user to the page location exactly as it was before, e.g. he could scoll a few lines down the anchor, click on the link, then when he returns, he will be at that few lines down the anchor, and not at the anchor
is it possible? anyone with any ideas??
|
|

February 21st, 2004, 12:58 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
You could do the following to preserve a page's scroll position:
1) Create a hidden field in the form to save the value.
2) In the body onScroll event you need to run the following javascript
myForm.myHiddenScrollField.value=document.body.scr ollTop;
3) All links on the page must force a post of the form. You could have the page post to itself, then you need to determine what link/button was pressed to determine what you would need to do. (i.e. For regular links, you would need to redirect to the correct page.)
4) When the page processes the form, save the hidden field's value to a session variable.
5) When the page draws itself, put the following in the body onLoad attribute:
document.body.scrollTop=<value from the session variable>;
This will reposition the document to the saved scroll position.
The biggest impact of this process will be on what you have to change for links. You won't be able to link directly to other pages, you will have to always cause a form post, otherwise you won't be able to preserve the value.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

February 21st, 2004, 02:08 AM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
w0o0o
thanks bmains for ur suggestion, and
thanks alot planoie, your suggestion works nicely
|
|
 |