Disable code if a handheld device?
Permalink
Is there a way to disable a few lines of code if the user is viewing the website on a handheld device?
I have a BG image that I need to switch off but it is loaded using JS so I want to disable the JS altogether
Thanks in advance
----
Edit: I have just found this...
http://detectmobilebrowsers.mobi/...
reading through it now
I have a BG image that I need to switch off but it is loaded using JS so I want to disable the JS altogether
Thanks in advance
----
Edit: I have just found this...
http://detectmobilebrowsers.mobi/...
reading through it now
Hey 12345j
Thanks for this. I suppose for me I would need:
So normal computers will use the code and mobile devices won't
Many thanks again
Thanks for this. I suppose for me I would need:
<?php if ($device != "mobile"); ?> my line of javascript <?php endif; ?>
So normal computers will use the code and mobile devices won't
Many thanks again
sorrey for not replying sooner, i didn't get the email. I believe negatives for php go at the beginning of the rule- so it would be something like but im not great at php. I might link it in with an if else though, so
but that could be just me. I guess its just my coding style, but thats what I like to do.
if (!$device == "mobile")
if ($device == "mobile"){ // link to mobile.css if you want a bg color } else { // javascript here }
but that could be just me. I guess its just my coding style, but thats what I like to do.
will detect mobile browsers and give them the name mobile. then call $device == "mobile" for further use (or you could wrap this in an if else statement