开发者

On click save link to variable and redirect to differnet link

开发者 https://www.devze.com 2023-03-07 03:47 出处:网络
I have a webpage with many links on it. I want to add a script to work through out the whole page that when any link on the page is clicked on the page it will save that link to a variable and then re

I have a webpage with many links on it. I want to add a script to work through out the whole page that when any link on the page is clicked on the page it will save that link to a variable and then redirect to to www.redirectlink.com

SO far I have

$('a'开发者_Python百科).click(function(){
location.href='http://www.redirectlink.com';
return false;
});

Is this right and how would I make it save the original url in a variable that I can use later on on the www.redirectlink.com page


$('a').click(function(e){
    e.preventDefault();
    document.location.href='http://www.redirectlink.com?ref='+this.href;
    return false;
});

You can now use $_REQUEST['ref'] in the redirectlink to check the refferer.

0

精彩评论

暂无评论...
验证码 换一张
取 消