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

02-17-2009, 02:45 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 12-14-08
Posts: 140
|
|
"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
|

02-17-2009, 07:38 PM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
|
|
|
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?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

02-17-2009, 07:49 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 12-14-08
Posts: 140
|
|
|
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?
|

02-17-2009, 08:29 PM
|
 |
Super Moderator
|
|
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 18,101
|
|
|
|

02-18-2009, 09:43 AM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
|
|
|
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..
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

02-18-2009, 10:17 AM
|
 |
Super Moderator
|
|
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 18,101
|
|
|
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?
|

02-18-2009, 10:41 AM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
|
|
|
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.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

02-18-2009, 04:23 PM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-11-07
Posts: 238
|
|
|
I know it's not exactly the same, but since you're using php, why don't you just use
$_SERVER['HTTP_REFERER']
|

02-19-2009, 03:54 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 12-14-08
Posts: 140
|
|
|
cross compatible?
|

02-19-2009, 06:58 AM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
|
|
|
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.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|

02-19-2009, 07:29 AM
|
|
Contributing Member
Latest Blog: None
|
|
Join Date: 06-11-07
Posts: 238
|
|
|
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>
|

02-20-2009, 08:39 AM
|
 |
v7n Mentor
Latest Blog: None
|
|
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
|
|
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>
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:28 PM.
Powered by vBulletin Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP
|
|
|