问题描述
我使用以下HTML片段为智能手机加载不同的样式表:
media =仅屏幕和(min - 设备宽度:4801x)
media =唯一屏幕和(最大设备宽度:480px)
我想为智能手机用户禁用特定的JavaScript脚本。那可能吗?我不认为我可以这样做:
< script media =only screen and(max-device-width:480px)t ype =text / javascriptsrc =/>
谢谢
您可以在javascript中检测屏幕分辨率,然后根据分辨率更改脚本执行。但JavaScript文件仍将被加载。检测屏幕大小:
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脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!