相关疑难解决方法(0)

设置JQuery event.preventDefault()时,在window.open上绕过弹出窗口阻止程序

我想在超链接的单击事件上有条件地显示JQuery对话框.

我有条件,例如在条件1上打开一个JQuery对话框,如果不满足条件1,则导航到由'href'标签引用的页面,该标签的点击事件有问题.

我能够在链接的点击事件上调用一个函数.此函数现在通过执行另一个URL(执行我的Spring控制器并返回响应)来检查所述条件.

所有的作品都只有window.open被弹出窗口拦截器阻挡.

$('a[href*=/viewpage?number]').live('click', function(e) {
    e.preventDefault();
    redirectionURL = this.href;
    pageId= getUrlVars(redirectionURL)["number"];
    $.getJSON("redirect/" + pageId, {}, function(status) {
        if (status == null) {
            alert("Error in verifying the status.");
        } else if(!status) {
            $("#agreement").dialog("open");
        } else {
            window.open(redirectionURL);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

如果我e.preventDefault();从代码中删除,popoup阻止程序不会阻止页面,但是对于condition1,它会打开对话框并打开'href'页面.

如果我解决了一个,它会为另一个人带来问题.我无法同时兼顾两种情况.

你能帮我解决这个问题吗?

一旦这个问题得到解决,我还有另外一个问题需要解决,即导航对话的OK事件:)

jquery window.open popup-blocker jquery-callback

96
推荐指数
5
解决办法
17万
查看次数

弹出窗口阻止chrome中的gdrive授权

因此,问题是弹出窗口阻止窗口打开,即使它是由用户操作完成的,单击例如..

gapi.auth.authorize({
   client_id: this.client_id,
   scope: this.scopes,
   access_type: 'online',
   immediate: immediate
}, function(authResult) {
   console.log(authResult)
});
Run Code Online (Sandbox Code Playgroud)

如果我只是在用户点击打开窗口,如下所示:

$('.some').click(funciton(){
    window.open(someurl)
})
Run Code Online (Sandbox Code Playgroud)

它工作正常,但如果我这样做它抛出gdrive api(gapi.auth.authorize),无论如何这个阻塞.

必须,我不能强迫用户关闭popap阻止.我希望现在有人如何解决它:),谢谢

javascript authentication google-drive-api

4
推荐指数
1
解决办法
3613
查看次数