问题
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. But the function below is not giving any response. Any other way to open jquery popups on page load??
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
回答1:
I think you should use ||
instead of &&
beacuse a variable can't be empty
and null
in the same time
if( access_token=="" || access_token==null){
$( "#popupDialog1" ).click(); //try with click()
}
回答2:
There is no such thing in jQuery or jQueryUI, it's a jQueryMobile method.
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/
回答3:
Check the undefined for 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" )
}
来源:https://stackoverflow.com/questions/23362241/jquery-popup-open-not-working