
对我来说小小是美好的因此我正在使用这些技术:在CSS文件中:/* Smartphones ----------- */@media only screen and (max-width: 760px) { #some-element { display: none; }}在jQuery / JavaScript文件中:$( document ).ready(function() { var is_mobile = false; if( $('#some-element').css('display')=='none') { is_mobile = true; } // now i can use is_mobile to run javascript conditionally if (is_mobile == true) { //Conditional script here } });我的目标是让我的网站“移动友好”。

所以我使用CSS Media Queries根据屏幕大小显示/隐藏元素。例如,在我的移动版本中,我不想激活Facebook Like Box,因为它会读取所有那些配置文件图像和内容。这对移动访问者来说并不好。所以,除了隐藏容器元素之外移动设备检测,我还在jQuery代码块(上面)中执行此操作:if(!is_mobile) { (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/pt_PT/all.js#xfbml=1&appId=210731252294735"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));}您可以在上看见它的实际效果我还在研究移动版本移动设备检测,所以它依然没有看起来应该这么。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-121257-1.html
我终于醒了
我怎么感觉你是来秀优越感的呢
支持台湾人民