2
$(window).unload(function() {
    var c = confirm("Are You want to open Foortal.pk");
    if (c) {

        window.location.replace("http://www.google.com")

        return true;
    } else {
        return false;
    }
});​

我不知道问题

4

4 回答 4

3

工作演示 http://jsfiddle.net/FUXRF/

阅读此 ==> https://forum.jquery.com/topic/jquery-onbefore-unload-and-page-redirect

:)我希望每个人都能像火箭一样工作

代码

$(window).unload(function() {
    var c = confirm("Are You want to open Foortal.pk");
    if (c) {
        alert(window.location);
       // window.location.replace("http://www.google.com");
        window.parent.location = "http://www.google.com";
        return true;
    } else {
        return false;
    }
});

$(window).trigger('unload');
​
于 2012-10-11T21:35:52.163 回答
1
window.parent.location ="http://www.google.com";

用那个代替

window.location.replace("http://www.google.com");
于 2012-10-11T21:30:47.970 回答
0

你忘了';' 上

window.location.replace("http://www.google.com");
于 2012-10-11T21:35:38.747 回答
0

我们这样做

   $(window).bind("beforeunload", function(){
        return "Are you OK?";
    });

尝试

   $(window).bind("beforeunload", function(){
        var c = confirm("Are You want to open Foortal.pk");
        if (c) {

            window.location("http://www.google.com");

            return true;
        } else {
            return false;
        }
    });
于 2012-10-11T21:27:50.927 回答