简体   繁体   English

jQuery弹出窗口。(“打开”)不起作用

[英]JQuery popup.(“open”) not working

I'm trying to open a popup window as soon as my page gets load with the help of .ready() function and below is the code within it. 我正在尝试通过.ready()函数加载页面时打开一个弹出窗口,下面是其中的代码。 But the function below is not giving any response. 但是下面的函数没有给出任何响应。 Any other way to open jquery popups on page load?? 还有其他方法可以在页面加载时打开jquery弹出窗口吗?

if( access_token==""&&access_token==null)
                 {
$( "#popupDialog1" ).popup( "open" )
}

The above code is integrated for an android app to be devloped using phonegap,html5,javascript etc 上面的代码已集成为使用phonegap,html5,javascript等开发的android应用

I think you should use || 我认为您应该使用|| instead of && beacuse a variable can't be empty and null in the same time 而不是&&因为变量不能同时为empty null

if( access_token=="" || access_token==null){
    $( "#popupDialog1" ).click();             //try with click()
}

There is no such thing in jQuery or jQueryUI, it's a jQueryMobile method. jQuery或jQueryUI中没有这样的东西,它是jQueryMobile方法。

So the problem you're currently facing probably have something to do with the fact that you didn't initialize the popup before. 因此,您当前面临的问题可能与您之前没有初始化弹出窗口有关。

Try this (use the two lines). 试试这个(使用两行)。

$( "#popupDialog1" ).popup();
$( "#popupDialog1" ).popup( "open" );

You can also play with this jsBin http://jsbin.com/laceboni/1/ 您也可以使用此jsBin http://jsbin.com/laceboni/1/

Check the undefined for access_token. 检查未定义的access_token。

access_token == undefined

And change the logical operator from && to || 并将逻辑运算符从&&更改为|| as you are checking two values for same variable at same time. 因为您要同时检查两个变量的值。

if( access_token=="" || access_token==null || access_token==undefined)
{
     $( "#popupDialog1" ).popup( "open" )
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM