Redirect traffic based on "?ref=XXX" at end o URL

This question already has an answer here:

  • How to get the value from the GET parameters? 45 answers

  • use this function with the parameters matters

    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[[]]/g, "$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/+/g, " "));
    }
    

    Code Source: first answer here How can I get query string values in JavaScript?

    and than create your link to redirect, and finally redirect usingo window.location = 'tour-url';

    链接地址: http://www.djcxy.com/p/34740.html

    上一篇: 如何检索wordpress根目录下的自定义字段?

    下一篇: 根据“URL ref = XXX”重定向流量