Link with 2 functions - depending on reference page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kaster
    New Member
    • Nov 2008
    • 6

    #1

    Link with 2 functions - depending on reference page

    Hi.
    I need to make a link on various pages with 2 functions.
    One that just act like browser-goback if vistor entered from a list-page.
    And an ordinay linkfunction (where visitor will enter at the top) when reference page is any other than the list-page.

    Have tried with this script
    Code:
      function mylist()
    {   if(document.referrer === "list-page.htm"){
                history.back();
            } else {
                document.location = "list-page.htm"
            } }
    with link:
    Code:
    <a href="javascript:void(0)" onClick="return mylist()"</a>
    It doesn´t work. Can anyone come up with a code that could do it, I would be really happy.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    your link is completely invalid.

    better go along
    Code:
    <span class="link">back</span>
    and use the class to style it as link as well as attaching the click event.

    Comment

    • Kaster
      New Member
      • Nov 2008
      • 6

      #3
      Yes, sorry I misssed a >
      Code:
      <a href="javascript:void(0)" onClick="return mylist()"[B]>[/B]</a>
      The link normally works and is class styled as you propose with an image.

      Comment

      Working...