在智能手机上加载时禁用JavaScript脚本 [英] disabling a javascript script when loaded on a smart phone

查看:370
本文介绍了在智能手机上加载时禁用JavaScript脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下HTML片段为智能手机加载不同的样式表:

  media =仅屏幕和(min - 设备宽度:4801x)
media =唯一屏幕和(最大设备宽度:480px)

我想为智能手机用户禁用特定的JavaScript脚本。那可能吗?我不认为我可以这样做:

< script media =only screen and(max-device-width:480px)t ype =text / javascriptsrc =/>



谢谢

您可以在javascript中检测屏幕分辨率,然后根据分辨率更改脚本执行。但JavaScript文件仍将被加载。检测屏幕大小:

http ://www.pageresource.com/jscript/jscreen.htm

I am using the following HTML fragment to load a different stylesheet for smartphones:

media="only screen and (min-device-width: 4801x)"
media="only screen and (max-device-width: 480px)"

I would like to disable a certain javascript script for smartphone users as well. Is that possible? I don't think i can do:

<script media="only screen and (max-device-width: 480px)" t ype="text/javascript" src=""/>

Thanks

解决方案

You can detect the screen resolution in javascript and then change script execution based on the resolution. But the javascript file will still be loaded. To detect the screen size:

http://www.pageresource.com/jscript/jscreen.htm

这篇关于在智能手机上加载时禁用JavaScript脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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