Disable Script For Mobiles
Solution 1:
What is the : false
after $(window).stellar()
? I'm not sure what you're trying to do there, or if it's just some kind of copy/paste error or something, but that will give:
SyntaxError: Unexpected token :
I think you want this:
jQuery(document).ready(function(){
if( !isMobile.any()){
$(window).stellar();
}
});
Solution 2:
jQuery(document).ready(function(){
if( !isMobile.any()){
$(window).stellar(): false;
}
});
That third line is syntactically wrong. What exactly are you trying to achieve with something likefn(): false;
?
I believe you're looking for:
jQuery(document).ready(function(){
if( !isMobile.any() ){
$(window).stellar();
}
});
In other words: only if !isMobile.any()
should $(window).stellar()
be executed. In the other case (where isMobile.any()
is true
), the if
block should not be executed.
Solution 3:
Open up the console in your browser.
Go to this fiddle: http://jsfiddle.net/vyPjx/
You will see the error
UncaughtSyntaxError: Unexpected token :
The error will point to the line
$(window).stellar(): false;
Looks like you were trying to use a ternary operator but you are not?
It should be just
$(window).stellar();
If you were going the ternary route it would have been
jQuery(document).ready(function(){
var hasRun = !isMobile.any() ? $(window).stellar() : false;
});
Solution 4:
Try this,
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
}
};
var any=(isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
jQuery(document).ready(function(){
if(!any){
alert('No mobiles');
$(window).stellar();
}
});
Post a Comment for "Disable Script For Mobiles"