Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I manipulate the "back" function? 1

Status
Not open for further replies.

cactus1000

Programmer
Aug 31, 2001
149
US
Here's my problem: My webpage has a browser-sniffer that works in the following way -- my index.html page is a non-javascripted web page. Upon loading, it checks for your browser version. If it's Netscape or IE 4x or higher, it redirects you to index1.html, a javascripted version.

So when you are on the javascripted page, if you click on the browser's "back" button, you go back to index.html -- which then checks your browser version and redirects you to index1.html, ad infinitum.

I know how to use the history.go method, but I don't want to add a "back" button to my web page. I want the user to use the browser's "back" button, but go back two URLs rather than one.

Any suggestions?
 
Nope...there isn't a way...I've asked this also in relation to Flash...Flash has to have back buttons, etc added to a page to be able to move back and forth...I didn't want that...as far as I could tell, Netscrap was going to add an object model for the back button, but alas, that idea got killed...someone mentioned to me perhaps altering the users history to go back to a certian page, but in flash it wouldn't have worked because it would have to reload the flash swf......it might work in your case...or, why not detect a browser version and do an include?...

Like, if browser = netscape, document.write (include statement) NS.inc...and NS.inc has all of your netscrap code...thats the best way I can think of it...redesign of options, or altering history... Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Naturally, you are redirecting browsers to a JavaScript enabled page. This means that those browsers are JavaScript enabled. Therefore, in the original page, use the location.replace() method to navigate them to the 2nd page. That method will replace the first page in session history with the new page and the back button will not take them back to the original page.

Let me know if you need details regarding this method.

TW
 
Sorry, I shouldn't have said that the location.replace() method would replace the first page in session history. It will replace the current page in session history with the page you are going to. Therefore, it will still meet your needs. A user pressing the back button will technically go back 2 pages because the page you redirected them from has been replaced in session history.

Give it a try. It works great.

TW
 
He cactus1000,

This has noting to do with your problem in this post but I saw your post in WhiteTiger's post "Need Examples of 'Natural Webpages'" and because you didn't marked that thread I thought this would be the place to let you know. (pff, a long sentence for a non English/American guy :))

I looked at the site you mentioned there and saw that only button 2 has the whole blue rectangle as "link-area"

You can see the differences:

button 1
<AREA SHAPE=&quot;rect&quot; COORDS=&quot;5,4,119,50&quot; HREF=
button 2
<AREA SHAPE=&quot;rect&quot; COORDS=&quot;6,8,148,66&quot; HREF=

It's not so bad, but the point is that after you click there will stay a dotted line around the area and with button 2 this dotted line is exactly at the edge of the blue rectangle so users don't actualy see that.

By the way, I know in a link you can get rid of that dotted with: <A onfocus=&quot;blur()&quot; href=&quot;...

I don't know if it works in <AREA> but you can try.

Further you only speciified the width and height of the images in button 2. They learned me allways to specify width and height because then the browser resreve a space for the image and will continue with publishing the other page-text instead of waiting for the whole image is downloaded.

Hope it will help you,
Erik
 
Not a bad workaround Todd...it wouldn't help me in my case, but oh well...=)...

So basically, it just doesn't record that '2nd' page in your history...it just replaces your current page...so when you go back, it's technically going back 2 pages, correct?...

Not bad not bad...*clap clap clap*...good show jolly 'ol chap! Regards,
Anth:cool:ny
----------------------------------------
&quot;You say [red]insanity[/red] like it's a BAD THING!&quot;
 
Well, here is a good example of how I use it in my application.

At an early point in a users session, they get to a point where they specify certain groups to base their data session on. Once they specify those groups and start their data session, I use the location.replace() method in javascript for ALL of the navigation in the data session. Since I am using ASP extensively, the back button is very unfriendly in my application. Therefore, by implementing that, no matter how many pages the visitors request in the data session, one click of the back button takes them right back to the group selection page.

It's been a huge headache and timesaver over trying to create solutions for &quot;Back&quot; button problems.

TW
 
Thanks ToddWW! location.replace works great.

Boomerang - I don't see the dotted lines in IE5 or Netscape 4.7, but I know what you mean, I've seen this in other browsers. I'll fix it if I have time, but this is a &quot;temporary&quot; site that will be taken down in about three weeks anyway. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top