jquery media handheld only screen
- Started
- Last post
- 6 Responses
- attentionspan
Is there any way to contro which jquery script gets shown based on screen size, like in css
@media handheld, only screen and (max-width: 767px)
thanks
- vaxorcist0
possibly a PHP/javascript hack.... like this (unless qbn tweeks code to be unreadable...)
<?
if(!isset($_GET['r']))
{
echo "<script language=\"JavaScript\">
<!--
document.location=\"$PHP_SELF?r=1&width=\"+screen.width+\"&Height=\"+screen.height;
//-->
</script>";
}
else {// Code to be displayed if resolutoin is detected
if(isset($_GET['width']) && isset($_GET['Height'])) {
// Resolution detected
}
else {
// Resolution not detected
}
}?>
- moth0
Bit messy no?
Use jQuery;
$(window).load(
function() {
if($("#container").width()>=767) {
}
}
);- jQuery is self-aware.mikotondria3
- yes.... waaay better than the kludge-o-matic php js soluitionvaxorcist
- monNom0
var touch = ''createTouch' in document;
if(touch){
//this is a touch enabled device
}
- monNom0
^ and if that wasn't clear enough. stick this in the if block for touch-screen, and do another in an else block for normal users
var scrp = document.createElement('script...
scrp.type = 'text/javascript';
scrp.src = 'touch.js'; //your script path goes here
document.getElementsByTagName('h...
- monNom0
document .getElementsByTagName ('head') .appendChild (scrp);
(spaces added)