Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Browser history

Reply
Thread Tools

Browser history

 
 
Linda
Guest
Posts: n/a
 
      08-09-2010
<input type="button" value="Back" onClick="javascript:
history.go(-1)">

In the previous page, the link to the current page is at the bottom of
the page. When I hit the back button on the current page, when the
previous page loads, it opens near the bottom of the page (where the
link is located). Is there a way to make the previous page open at
the top of the page using the onclick of this button?

Linda
 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      08-09-2010
On Aug 9, 12:51*am, Linda <(E-Mail Removed)> wrote:
> <input type="button" value="Back" onClick="javascript:
> history.go(-1)">


That should be avoided, meaning both the "javascript:" label (which
does nothing here) and the use of the history.go method.

>
> In the previous page, the link to the current page is at the bottom of
> the page. *When I hit the back button on the current page, when the
> previous page loads, it opens near the bottom of the page (where the
> link is located). *Is there a way to make the previous page open at
> the top of the page using the onclick of this button?
>


Yes, if you know the address of the previous page you could set
window.location.href. Of course, then you could use a static link
instead of a scripted button.
 
Reply With Quote
 
 
 
 
Garrett Smith
Guest
Posts: n/a
 
      08-09-2010
On 2010-08-08 09:51 PM, Linda wrote:
> <input type="button" value="Back" onClick="javascript:
> history.go(-1)">
>

Don't use javascript URIs.
<http://jibbering.com/faq/#javascriptURI>

What if it is an off-site link, or if there is no referring link?

A link is the way to go; you'll need some sort of server side logic to
get that URI.

> In the previous page, the link to the current page is at the bottom of
> the page. When I hit the back button on the current page, when the
> previous page loads, it opens near the bottom of the page (where the
> link is located). Is there a way to make the previous page open at
> the top of the page using the onclick of this button?
>

What for? That sounds like a broken experience.
--
Garrett
 
Reply With Quote
 
Garrett Smith
Guest
Posts: n/a
 
      08-09-2010
On 2010-08-08 10:56 PM, Garrett Smith wrote:
> On 2010-08-08 09:51 PM, Linda wrote:
>> <input type="button" value="Back" onClick="javascript:
>> history.go(-1)">
>>

> Don't use javascript URIs.
> <http://jibbering.com/faq/#javascriptURI>
>


Sorry, that was not a javascript uri you used; but a meaningless label.
You don't need that label and if you use a real link (as I suggested in
my previous message) you're much better off.
--
Garrett
 
Reply With Quote
 
Linda
Guest
Posts: n/a
 
      08-09-2010
OK. I get it that no one here thinks that this is a good idea. But,
without going into a long description of the "why" I want to do this,
is there a way to return to the top of an unknown page with a link or
with a button rather than to the point of the link on the referring
page?

Linda
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-09-2010
Garrett Smith wrote:

> Garrett Smith wrote:
>> Linda wrote:
>>> <input type="button" value="Back" onClick="javascript:
>>> history.go(-1)">

>>
>> Don't use javascript URIs.
>> <http://jibbering.com/faq/#javascriptURI>

>
> Sorry, that was not a javascript uri you used; but a meaningless label.


It is not always considered a meaningless label (and might even be
considered a syntax error), but given JScript being the default in MSHTML,
and its VBScript not being universally supported client-side, the label
should not be necessary to use.

> You don't need that label


There is not enough information in the posting to support that assumption.

> and if you use a real link (as I suggested in my previous message) you're
> much better off.


ACK


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
Denis McMahon
Guest
Posts: n/a
 
      08-09-2010
On 09/08/10 16:06, Linda wrote:
> OK. I get it that no one here thinks that this is a good idea. But,
> without going into a long description of the "why" I want to do this,
> is there a way to return to the top of an unknown page with a link or
> with a button rather than to the point of the link on the referring
> page?


I think it's a feature of the way some browsers handle cached pages.

I suspect that some browsers remember where on the page the user was
looking when they navigated away from the page, and if they return to
the page eg using the back button, it takes them back to where they were.

Whether it can be over-ridden or not by anything you do server-side or
in the html I have no idea, although expiring the page might help.

Rgds

Denis McMahon
 
Reply With Quote
 
Felix Palmen
Guest
Posts: n/a
 
      08-09-2010
* Denis McMahon <(E-Mail Removed)>:
> On 09/08/10 16:06, Linda wrote:
>> OK. I get it that no one here thinks that this is a good idea. But,
>> without going into a long description of the "why" I want to do this,
>> is there a way to return to the top of an unknown page with a link or
>> with a button rather than to the point of the link on the referring
>> page?

>
> I suspect that some browsers remember where on the page the user was
> looking when they navigated away from the page, and if they return to
> the page eg using the back button, it takes them back to where they were.


Right, and in my experience, this feature is canceled by any manual
scrolling action of the user, so /maybe/ a window.scrollTo(0,0) would
cancel it, too. Still that means disabling a useful feature...

Regards, Felix

--
Felix Palmen (Zirias) + [PGP] Felix Palmen <(E-Mail Removed)>
web: http://palmen-it.de/ | http://palmen-it.de/pub.txt
my open source projects: | Fingerprint: ED9B 62D0 BE39 32F9 2488
http://palmen-it.de/?pg=pro + 5D0C 8177 9D80 5ECF F683
 
Reply With Quote
 
Garrett Smith
Guest
Posts: n/a
 
      08-09-2010
On 2010-08-09 08:06 AM, Linda wrote:
> OK. I get it that no one here thinks that this is a good idea. But,
> without going into a long description of the "why" I want to do this,
> is there a way to return to the top of an unknown page with a link or
> with a button rather than to the point of the link on the referring
> page?
>


A fragment identifier is the way to do that:
<a href="/#top">Go Back</a>

For help on posting and replying, I suggest you read:
<http://jibbering.com/faq/#posting>
--
Garrett
 
Reply With Quote
 
Linda
Guest
Posts: n/a
 
      08-10-2010
On Aug 9, 5:58*pm, Garrett Smith wrote:

> A fragment identifier is the way to do that:
> <a href="/#top">Go Back</a>


This looked interesting. I tried using it as written but it did not
work as I expected. I am using Safari 5.0.1 on Mac OS X. When I
click on the Go Back link, it opens Finder to the root directory on
the Mac.

Linda
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using history.go() to get to the *last* item in the history Niall Javascript 3 12-06-2006 03:26 PM
Values entered in the Form disappears when using the history.go(-1) or history.back() sujith.bolar@gmail.com Javascript 2 10-17-2006 08:12 PM
Recover Firefox web search history with history set to 0 days Sudip Chakraborty Firefox 2 11-21-2005 06:47 PM
[ANN] irb-history 1.0.0: Persistent, shared Readline history for IRB Sam Stephenson Ruby 1 06-18-2005 08:56 AM
history.dat, formhistory.dat - deleting deletes history? S.Rodgers Firefox 4 05-05-2005 01:03 AM



Advertisments