Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
Thread Tools
Share |
 
Old 02-17-2009, 03:45 PM
2939195631902 2939195631902 is offline
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
Lightbulb "back button script" javascript:history.go(-1) doesn't work in IE??

I've been using this script for a back button i built for my site.


<a href="javascript:history.go(-1)"><div id="back_button"><img src="../direct_images/back_button.gif" /></div></a>


However, i had just realized it does work for IE while works fine in other browsers including chrome, ff, ...

Does anyone know whats wrong with this piece of code?

Thx
 

Advertisement

Advertisement

 
Old 02-17-2009, 08:38 PM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Hmm, not the best way to go back to a previous page, but this should work fine in IE7.

Can you post the code around this?
 
 
Old 02-17-2009, 08:49 PM
2939195631902 2939195631902 is offline
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
Well, i pasted the same code:

<a href="javascript:history.go(-1)"><div id="back_button">Back</div></a>

into a new .php page to see if it works or not.

And it does work in chrome but not IE7. I thought it might be my browser, but then i found out that code doens't work in FF either.

As of right now, the new page test.php with that back button statement has no other codes in the page.

Any more suggesitons?
 
 
Old 02-17-2009, 09:29 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,707
iTrader: 5 / 100%
The JavaScript Source: Navigation: Back Button
 
 
Old 02-18-2009, 10:43 AM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Good link, but that doesn't seem to work.

I haven't used this type of JavaScript back button in a long time! So, maybe the new versions of browsers have deprecated it? Not sure..
 
 
Old 02-18-2009, 11:17 AM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,707
iTrader: 5 / 100%
Works in IE7 and FF3.

Maybe because this forum is set up to open links in a new window, you didn't have a previous page to go back to?
 
 
Old 02-18-2009, 11:41 AM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Hmm, that would have been why. Can't believe I didn't notice that! lol...

Had a weird reaction though, it was go forward instead in FF (just go forward to the same page). Weird.
 
 
Old 02-18-2009, 05:23 PM
Capo64 Capo64 is offline
Contributing Member
 
Join Date: 06-11-07
Posts: 238
iTrader: 0 / 0%
I know it's not exactly the same, but since you're using php, why don't you just use
$_SERVER['HTTP_REFERER']
 
 
Old 02-19-2009, 04:54 AM
2939195631902 2939195631902 is offline
Contributing Member
 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
cross compatible?
 
 
Old 02-19-2009, 07:58 AM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Well, as long as your server supports PHP, then yes. But it's not javascript. Instead this will sender a header to your browser telling it to go to another page, which is compatible in all browsers.
 
 
Old 02-19-2009, 08:29 AM
Capo64 Capo64 is offline
Contributing Member
 
Join Date: 06-11-07
Posts: 238
iTrader: 0 / 0%
if you set up a link like this:

<a href="<?=$_SERVER['HTTP_REFERER']?>">Go Back</a>

And you clicked a link from google.com to come to your website. It will render like this:

<a href="http://www.google.com">Go Back</a>
 
 
Old 02-20-2009, 09:39 AM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Capo is correct. That would be the way to do it.

Except that's ASP style, and most servers don't support that.

So it would actually be:

PHP Code:
<a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Go Back</a>
 
Go Back   Webmaster Forum > Web Development > Coding Forum

 
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
should a navigation bar include a "home" button? BostonWebPaul Web Usability 25 08-13-2011 07:28 AM
Search engine bots "seeing through" Javascript? Shockt SEO Forum 2 12-03-2006 05:13 PM
Home page with "latest news", "news archive" and "update" tekitouni Web Design Lobby 1 09-19-2006 07:39 PM
Funny JavaScript "complicatedness"! webzenstar Coding Forum 2 09-17-2006 12:57 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 09:55 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC