Welcome Guest, Not a member yet? Register   Sign In
JQuery question (link history)
#1

[eluser]Référencement Google[/eluser]
Hi all,

How can I make such a thing with a JQuery listner rather than having a href with javascript inside:
Code:
<a href="[removed]history.back();">Back</a>

Hmmm the forum add a [removed] tag but normally it's write with "javascript" inside
#2

[eluser]Quin Hoxie[/eluser]
You can use jQuery's bind function to achieve this like so:
Code:
<span id="hist">Back</span>

  $("#hist").bind('click', function() {
    history.back();
  });
#3

[eluser]Référencement Google[/eluser]
[quote author="mrapples" date="1212194612"]You can use jQuery's bind function to achieve this like so:
Code:
<span id="hist">Back</span>

  $("#hist").bind('click', function() {
    history.back();
  });
[/quote]

Ho thanks, that was really more simple that I thought !
#4

[eluser]Bramme[/eluser]
[quote author="elitemedia" date="1212194761"][quote author="mrapples" date="1212194612"]You can use jQuery's bind function to achieve this like so:
Code:
<span id="hist">Back</span>

  $("#hist").bind('click', function() {
    history.back();
  });
[/quote]

Ho thanks, that was really more simple that I thought ![/quote]

you can do that even shorter Wink
Code:
<span id="hist">Back</span>

  $("#hist").click(function() {
    history.back();
  });
More semantically correct would be (imo)
Code:
<a id="hist">Back</a>

  $("#hist").click(function() {
    history.back();
    return false;
  });
The return false is so the page won't actually follow the link. Though I don't know if it's necessary with the history back thing. You should try it out.
#5

[eluser]Référencement Google[/eluser]
Thank you for the tip Bramme




Theme © iAndrew 2016 - Forum software by © MyBB