刷新网页实际上是重定向到bing

时间:2014-10-29 07:15:56

标签: javascript jquery

我有一个脚本,我在其中将自定义URL添加到浏览器后退按钮

为此我使用了这个特殊的脚本

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/native.history.js"></script>
<script type="text/javascript" src="js/go.new.js"></script>
<script>
    $(window).load(function()
    {
        setTimeout(backtrap, 100);
        if (!($.cookie("clkd"))){
            $.cookie("clkd", 1, { expires : 14 , path: '/'});
        }
        setInterval(toggle_image, 1000);
    }); 

    window.onpageshow = function (e) {
        if (e.persisted) {
            location.reload();
        }
    };

    window.onpopstate = function(event) {
        if  (document.location.toString().indexOf("redir=1")>0){
            window.location.href = "<?=$$last_offer?>";
            //window.location.href = "<?=$szLinkURL?>";
        }
    };

    function toggle_image()
    {
        var height = $('#banner-img').height();
        $('#banner-img').toggle(); 
        $('#loader-img').toggle(); 
        $('#loader-img').css({'height':height+'px'}); 
    } 

    function show_star(rate,id)
    {
        $('#al-stars-'+id).html('<span class="stars" id="stars-'+id+'">'+parseFloat(rate)+'</span>');
        $('#stars-'+id).stars();
    }
    $.fn.stars = function() 
    {
        return $(this).each(function() {
            $(this).html($('<span />').width(Math.max(0, (Math.min(5, parseFloat($(this).html())))) * 16));
        });
    }        
</script>

现在脚本似乎工作正常,但我面临一个新问题,即:

当我点击浏览器上的刷新按钮时,页面将重新显示到bing.com

但我不知道为什么会这样......

如果需要,可以使用go.new.js

中的脚本
/**
 * go.js
 *
 * Functions for go.php and the backtrap
 */

// --------------------------------------------------------------------------------------------------------------------

// Code for parsing query string gratefully lifted from http://unixpapa.com/js/querystring.html, with an
// addition for modifying/generating new query strings.

// Query String Parser
//
//    qs= new QueryString()
//    qs= new QueryString(string)
//
//        Create a query string object based on the given query string. If
//        no string is given, we use the one from the current page by default.
//
//    qs.value(key)
//
//        Return a value for the named key.  If the key was not defined,
//        it will return undefined. If the key was multiply defined it will
//        return the last value set. If it was defined without a value, it
//        will return an empty string.
//
//   qs.values(key)
//
//        Return an array of values for the named key. If the key was not
//        defined, an empty array will be returned. If the key was multiply
//        defined, the values will be given in the order they appeared on
//        in the query string.
//
//   qs.keys()
//
//        Return an array of unique keys in the query string.  The order will
//        not necessarily be the same as in the original query, and repeated
//        keys will only be listed once.
//
//    QueryString.decode(string)
//
//        This static method is an error tolerant version of the builtin
//        function decodeURIComponent(), modified to also change pluses into
//        spaces, so that it is suitable for query string decoding. You
//        shouldn't usually need to call this yourself as the value(),
//        values(), and keys() methods already decode everything they return.
//
// Note: W3C recommends that ; be accepted as an alternative to & for
// separating query string fields. To support that, simply insert a semicolon
// immediately after each ampersand in the regular expression in the first
// function below.

function QueryString(qs)
{
    this.dict= {};

    // If no query string  was passed in use the one from the current page
    if (!qs) qs= location.search;

    // Delete leading question mark, if there is one
    if (qs.charAt(0) == '?') qs= qs.substring(1);

    // Parse it
    var re= /([^=&]+)(=([^&]*))?/g;
    while (match= re.exec(qs))
    {
        var key= decodeURIComponent(match[1].replace(/\+/g,' '));
        var value= match[3] ? QueryString.decode(match[3]) : '';
        if (this.dict[key])
        this.dict[key].push(value);
        else
        this.dict[key]= [value];
    }
}

QueryString.decode= function(s)
{
    s= s.replace(/\+/g,' ');
    s= s.replace(/%([EF][0-9A-F])%([89AB][0-9A-F])%([89AB][0-9A-F])/g,
        function(code,hex1,hex2,hex3)
        {
            var n1= parseInt(hex1,16)-0xE0;
            var n2= parseInt(hex2,16)-0x80;
            if (n1 == 0 && n2 < 32) return code;
            var n3= parseInt(hex3,16)-0x80;
            var n= (n1<<12) + (n2<<6) + n3;
            if (n > 0xFFFF) return code;
            return String.fromCharCode(n);
        });
    s= s.replace(/%([CD][0-9A-F])%([89AB][0-9A-F])/g,
        function(code,hex1,hex2)
        {
            var n1= parseInt(hex1,16)-0xC0;
            if (n1 < 2) return code;
            var n2= parseInt(hex2,16)-0x80;
            return String.fromCharCode((n1<<6)+n2);
        });
    s= s.replace(/%([0-7][0-9A-F])/g,
        function(code,hex)
        {
            return String.fromCharCode(parseInt(hex,16));
        });
    return s;
};

QueryString.prototype.value= function (key)
{
    var a= this.dict[key];
    return a ? a[a.length-1] : undefined;
};

QueryString.prototype.values= function (key)
{
    var a= this.dict[key];
    return a ? a : [];
};

QueryString.prototype.keys= function ()
{
    var a= [];
    for (var key in this.dict)
            a.push(key);
    return a;
};

QueryString.prototype.set = function(key, value)
{
    this.dict[key] = [value];
};

QueryString.prototype.add = function(key, value)
{
    if (typeof this.dict[key] == 'undefined') {
        this.dict[key] = [value];
    } else {
        this.dict[key].push(value);
    }
};

QueryString.prototype.toString = function()
{
    var pieces = [];

    for (var key in this.dict) {
        for (var idx in this.dict[key]) {
            pieces.push( encodeURIComponent(key) + '=' + encodeURIComponent(this.dict[key][idx]));
        }
    }

    return pieces.join('&');
};

// --------------------------------------------------------------------------------------------------------------------

// Load ourselves into the user's history, with an altered query string. The 'bt' var tells us what step of the
// back trap we were LAST on. After that, we redirect ourselves to the next URL.
function backtrap() {
    var qs = new QueryString();
    qs.set('redir', 1);
    var own_url = window.location.href;

    var qs_at = own_url.indexOf('?');
    var doped_url;

    if (qs_at == -1) {
        doped_url = own_url + '?' + qs.toString();
    } else {
        doped_url = own_url.substring(0, qs_at) + '?' + qs.toString();
    }
    History.pushState({}, '', doped_url);
    History.pushState({} ,'', own_url);
    alert(doped_url);
    alert(own_url);
}

为了更好地理解

检查此链接并检测

http://gomotrak.com/main/click.php?c=2173&key=jm64njqpq608t19bgqi3fwfq&c2=AA09_00000&c3=[zone]

[NOTE]

The backbutton is working fine, there is no issue with the back-button...

Problem is, when i am clicking on the refresh button of the browser in the address bar, its reloading the bing page.

$$last_offer也是绝对正确的,因为它以这种方式工作

if(stripos($ua,'android') !== false) 
    { 
        $agent = 'a';
        setlocale(LC_ALL, 'pt_BR.UTF-8');
        $last_CSVfp = fopen("offer_android.csv", "r");
        $last_offer_data = array();
        if($last_CSVfp !== FALSE) 
        {
            while(! feof($last_CSVfp)) 
            {
                $last_offer_data[] = fgetcsv($last_CSVfp,"",",");
            }
        }
        fclose($last_CSVfp);
        $last_arr_size = count($last_offer_data);
        $last_offer = "offer".intval(intval($last_arr_size)+1);
    }

因此$last_offer变为"offer3",例如

$$last_offer变为"$offer3",与alias变量php php变量的denoted by another类似

0 个答案:

没有答案
相关问题