By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,208 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,208 IT Pros & Developers. It's quick & easy.

Link with 2 functions - depending on reference page

P: 6
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
Expand|Select|Wrap|Line Numbers
  1.   function mylist()
  2. {   if(document.referrer === "list-page.htm"){
  3.             history.back();
  4.         } else {
  5.             document.location = "list-page.htm"
  6.         } }
with link:
Expand|Select|Wrap|Line Numbers
  1. <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.
Aug 24 '15 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
your link is completely invalid.

better go along
Expand|Select|Wrap|Line Numbers
  1. <span class="link">back</span>
and use the class to style it as link as well as attaching the click event.
Aug 24 '15 #2

P: 6
Yes, sorry I misssed a >
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onClick="return mylist()"></a>
The link normally works and is class styled as you propose with an image.
Aug 24 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.