PDA

View Full Version : bringing users back to where they were on page


Try_Try_Again
01-24-2003, 07:53 AM
Can someone please help me find some information on the following?

I have a page that's pretty long, and there are areas where people can hit a submit button to save changes. But after they click on it, it goes back up to the top of the page.--making the person scroll several pages down to see the change.

How do I make it so that after they click on Save Changes, it brings them back to where they were on the page?

I swear I've seen this done before but couldn't find the source again.

Any help would be appreciated.

Thanks!

redstormaudio
01-24-2003, 08:12 AM
Have you tried setting <a id="place" name="place"></a> near where you want them to return to and append #place to the form action?

I haven't tried this, but I think it should work.

Try_Try_Again
01-24-2003, 08:36 AM
Thanks for the suggestion. But, I was hoping to get something where I didn't have to specify the location. Instead, the person should just go back to where ever they were when they clicked on Save Changes.

Any other ideas?

Catman
01-24-2003, 02:39 PM
Try using a plain button rather than a submit button (either <input type="button"> or <button type="button"></button>).

MrDoubtFire
01-24-2003, 04:26 PM
Maybe you could note at what position the scrollbar is in, ie how far down the page it is? Then simply reset to that position again after it has brought the user back to the top of the page.

MrDoubtFire

Try_Try_Again
01-29-2003, 06:37 AM
still having a problem with this. is it even possible?

any info would be greatly appreciated.

applesauce
01-29-2003, 05:30 PM
i know this isn't what you were asking, but maybe it would be easier for your readers if you broke up the content over several pages. i think that easier on the eyes, and i tend to get lost on these long pages!
:)

Mr J
01-29-2003, 08:52 PM
When you submit does your page reload, if so I have a script that will do exactly what you want.




<SCRIPT LANGUAGE="JavaScript">
<!--
var db = (document.all) ? 1 : 0;
var scroll = (window.scrollTo) ? 1 : 0;

function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}

function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}

function saveScroll() {
if (!scroll) return;
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var x = (db) ? document.body.scrollLeft : pageXOffset;
var y = (db) ? document.body.scrollTop : pageYOffset;
setCookie("xy", x + "_" + y, now);
}

function loadScroll() {
if (!scroll) return;
var xy = getCookie("xy");
if (!xy) return;
var ar = xy.split("_");
if (ar.length == 2) scrollTo(parseInt(ar[0]), parseInt(ar[1]));
}

// -->
</SCRIPT>

<BODY onLoad="loadScroll()" onUnload="saveScroll()">

Try_Try_Again
01-31-2003, 11:59 PM
You are a genius. Thank you for your time and help.