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.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 02-17-2009, 03:45 PM
Contributing Member
Latest Blog:
None

 
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
 
Reply With Quote

Advertisement

Advertisement

  #2 (permalink)  
Old 02-17-2009, 08:38 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
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?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #3 (permalink)  
Old 02-17-2009, 08:49 PM
Contributing Member
Latest Blog:
None

 
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?
 
Reply With Quote
  #4 (permalink)  
Old 02-17-2009, 09:29 PM
HTMLBasicTutor's Avatar
Administrator
 
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 21,234
iTrader: 5 / 100%
The JavaScript Source: Navigation: Back Button
__________________

HTML Basic Tutor - Learn how to code for better SEO
Basic Computer Information - Computer & internet basics for website owners

SEO troubleshooting and review services available. - Pm me.
 
Reply With Quote
  #5 (permalink)  
Old 02-18-2009, 10:43 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
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..
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #6 (permalink)  
Old 02-18-2009, 11:17 AM
HTMLBasicTutor's Avatar
Administrator
 
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 21,234
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?
__________________

HTML Basic Tutor - Learn how to code for better SEO
Basic Computer Information - Computer & internet basics for website owners

SEO troubleshooting and review services available. - Pm me.
 
Reply With Quote
  #7 (permalink)  
Old 02-18-2009, 11:41 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
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.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #8 (permalink)  
Old 02-18-2009, 05:23 PM
Contributing Member
Latest Blog:
None

 
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']
 
Reply With Quote
  #9 (permalink)  
Old 02-19-2009, 04:54 AM
Contributing Member
Latest Blog:
None

 
Join Date: 12-14-08
Posts: 140
iTrader: 0 / 0%
cross compatible?
 
Reply With Quote
  #10 (permalink)  
Old 02-19-2009, 07:58 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
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.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #11 (permalink)  
Old 02-19-2009, 08:29 AM
Contributing Member
Latest Blog:
None

 
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>
 
Reply With Quote
  #12 (permalink)  
Old 02-20-2009, 09:39 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
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>
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
should a navigation bar include a "home" button? BostonWebPaul Web Usability 25 08-13-2011 08: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 08:39 PM
Funny JavaScript "complicatedness"! webzenstar Coding Forum 2 09-17-2006 01:57 AM


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


All times are GMT -7. The time now is 12:03 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2014 Escalate Media




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.