onMouseDown event help
Im having some problem with onMouseDown event.
So like when you go to Google and click on a search result... something like this gets prefixed to the landing page:
http://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CDcQFjAB&url
$(document).ready(function () {
var count = 0;
var matchavailable = 0;
var protectedlinks = "google.com,yahoo.com";
$("a").mousedown(function () {
var linkArray = protectedlinks.split(',');
for (var i = 0; i < linkArray.length; i++) {
if ($(this).attr('href').indexOf(linkArray[i]) > 0) {
matchavailable = 1;
break;
}
else {
matchavailable = 0;
}
}
if (matchavailable == 0) {
if (count == 0) {
$(this).attr('href', "http://localhost/wordpress/redirect.php?link=" + encodeURIComponent($(this).attr('href')));
$(this).attr('target', '_blank');
count = count + 1;
}
}
});
}); http://localhost/wordpress/redirect.php?link=
Suppose I have a lot of different website links like bing.com, warriorforum.com...the thing is, if I click on bing.com I get that redirect.php prefixed. However, right after that, when I try to do it on warriorforum .com link... nothing gets prefixed (and vica versa). What am I missing?
Hope I've been descriptive enough
-
Nathan K -
Thanks
{{ DiscussionBoard.errors[8503715].message }} -
-
brutecky -
Thanks
SignatureJoin over 7500 marketers on my Facebook group and also get tons of free tutorials and software to help you with your business.{{ DiscussionBoard.errors[8505148].message }} -
-
roady -
Thanks
Signature{{ DiscussionBoard.errors[8507085].message }} -
-
BuddhaOfCode -
[ 1 ] Thanks
{{ DiscussionBoard.errors[8507299].message }} -
-
roady -
Thanks
Signature{{ DiscussionBoard.errors[8511143].message }} -