我正在使用fb登录功能,但问题是,每当我在页面媒体加载完成之前单击fb登录按钮时,它会阻止fb登录的弹出窗口,但如果我在第二次传递给加载事件后点击fblogin它作品
这是我正在使用的功能:
function fb_login() {
var email='';
console.log(loginClassbackQueue);
// console.log('user wants to login with fb');
FB.getLoginStatus(function(response) {
if(response.status!='connected'){
FB.login(function(response) {
// console.log(response);
if (response.authResponse) {
// console.log('user logged in successfully');
// console.log(response);
email = update_f_data_login(response);
$('#fb_login_popup, #popup_overlay').hide();
// loginme(email);
}
else {
loginClassbackQueue = [];
// console.log('user failed to login');
}
// console.log('fb login completed successfully');
}, {scope:"email,user_birthday,user_likes,user_location,friends_likes,publish_actions"}
);
}
else{
// console.log('logged in and connected');
email = update_f_data_login(response);
$('#fb_login_popup, #popup_overlay').hide();
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我在这个网站上做同样的动作http://fab.com/它打开弹出窗口总是永远不会阻止弹出窗口.
重写问题 -
我正在尝试创建一个页面,如果用户离开页面(或者到其他链接/网站或关闭窗口/选项卡)我想显示onbeforeunloadhandeler说we have a great offer for you?,如果用户选择leave the page它应该做正常的传播,但如果他选择stay on the page我需要他将其重定向到提供页面redirection is important, no compromise.对于测试,我们可以重定向到google.com
我做了一个程序如下 -
var stayonthis = true;
var a;
function load() {
window.onbeforeunload = function(e) {
if(stayonthis){
a = setTimeout('window.location.href="http://google.com";',100);
stayonthis = false;
return "Do you really want to leave now?";
}
else {
clearTimeout(a);
}
};
window.onunload = function(e) {
clearTimeout(a);
};
}
window.onload = load;
Run Code Online (Sandbox Code Playgroud)
但问题是,如果他点击链接yahoo.com并选择leave the …