PHP的回声语句,如果屏幕是一定的大小 [英] php echo statement if screen is a certain size

查看:131
本文介绍了PHP的回声语句,如果屏幕是一定的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一系列jQuery脚本,仅当用户屏幕宽度大于960px时才要运行.我知道您无法使用php检测屏幕大小,但是有一种方法可以创建某种效果:

I have a series of jQuery scripts on my site that I want to only run if the users screen width is greater than 960px. I know that you can't detect screen size using php but is there a way to create something to this effect:

<? php 
if [METHOD TO DETECT SCREEN SIZE] > 960px {
echo '<script src="js/nbw-parallax.js" type="text/javascript"></script>';
}
?>

推荐答案

为什么不使用jQuery?

Why not use jQuery?

if( $(window).width() > 960 )
{
  $.ajax({
    url: 'js/nbw-parallax.js',
    dataType: "script",
    success: function() {
        //success
    }
  });
}

这篇关于PHP的回声语句,如果屏幕是一定的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆