Web Design Forum: Making a div link to previous page - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Making a div link to previous page

#1 User is offline   Funkybass99 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 09-November 11
  • Reputation: 0

Posted 08 February 2012 - 01:36 PM

Hi, I've created a div with an arrow for a background. I just want to make it link to the previous page.

I've tried using:

<div id="back_button" onclick=”location.href='javascript:history.go(-1)’">


but, while the onlick part will work on some text, it doesn't seem to want to work on the div. Any idea what I can do? Thanks.

This post has been edited by Renaissance-Design: 08 February 2012 - 01:49 PM
Reason for edit: Please use the code button or tags to format your code.

0

#2 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 08 February 2012 - 01:52 PM

What's wrong with the actual back button?

If you don't need the querystring from the previous page, you could use

<a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Back</a>

0

#3 User is offline   Funkybass99 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 09-November 11
  • Reputation: 0

Posted 08 February 2012 - 01:53 PM

This works:
<div id="back_button" onClick="history.go(-1);return true;">

This post has been edited by Renaissance-Design: 08 February 2012 - 01:56 PM
Reason for edit: Please use the code button or tags to format your code.

0

#4 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 08 February 2012 - 02:01 PM

Once more, what's wrong with the actual back button? Everybody knows it's there and uses it on the whole internet, as opposed to your solution, which they'll have to learn just for your site.

Finally, just because something works doesn't mean it's the right way to do it. What you're doing there is linking, so it should be an anchor element. Also, you shouldn't use inline Javascript event handlers.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users