?
Solved

is there a way of achieving this using jquery?

Posted on 2011-10-08
9
Medium Priority
?
197 Views
Last Modified: 2012-05-12
<a href="http://www.yahoo.com">yui</a>

when hover over yui, you see the link to yahoo, but if you click on it, it switches the link to google.com and takes you to google instead. Is this doable with jquery?

If yes, what's the code for it?
0
Comment
Question by:charmingduck
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36937890
You mean the techniques attempted by the phishers that send you links that look like they go to your bank but actually go to a Bulgarian hacker site which tries to steal your credit card details ?
0
 

Author Comment

by:charmingduck
ID: 36937994
no, im working on some affiliate programs, the actual link is www.somesite.com/username, but it takes you to www.somesite.com, however, with the username, the system is able to track who brought who to the site.

when you hover over a link, i want it to show www.somesite.com, but when they click on it, it takes you to www.somesite.com/username, i know there's a apache redirect that can do this, but i was wondering if it can be done with jquery.

Doable?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36938009
Jquery is not needed.
I would do
<a href="http://somesite.com" onclick="this.location=this.href+'/username';return false">click</a>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:charmingduck
ID: 36938040
i tried, it didn't work

??
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36938046
Sorry, remove the first this.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 36938052
Here


<a href="http://somesite.com" onclick="location=this.href+'/username';return false">click</a>


or if you must


<a class="afflink" id="afflink1" href="http://somesite.com">click</a>
<a class="afflink" id="afflink2" href="http://somesite.com">click</a>

<script type="text/javascript">
var affiliates = {
  afflink1:"someAffiliateUserId",
  afflink2:"someOtherAffiliateUserId" // no comma after the last
 }
$(document).ready(function() {
  $(".afflink").click(function() {
    location=this.href+"/"+affiliates[this.id]; // or $(this).attr("id")
  });
});
0
 

Author Comment

by:charmingduck
ID: 36938070
great, it worked

and it's clean, but do you mind showing me the way of doing this in jquery?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36938072
I did ;)
0
 

Author Comment

by:charmingduck
ID: 36938081
thanks, dude, you are awesome!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question