Wrox Programmer Forums
|
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
 
Old February 20th, 2004, 09:44 PM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old February 20th, 2004, 11:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old February 20th, 2004, 11:44 PM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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??

 
Old February 21st, 2004, 12:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old February 21st, 2004, 02:08 AM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

w0o0o
thanks bmains for ur suggestion, and
thanks alot planoie, your suggestion works nicely






Similar Threads
Thread Thread Starter Forum Replies Last Post
User's Exact Location (Country, City, Continent) [email protected] ASP.NET 1.0 and 1.1 Professional 3 March 8th, 2006 12:49 AM
How to return a string to it's exact original (len EDCH123 Java Databases 0 January 25th, 2006 04:06 PM
Location of Access default command button icons ActuaryTm Access 2 September 16th, 2005 12:03 PM
Back Button DARSIN General .NET 0 March 1st, 2005 08:00 AM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.