在移动网站上停用javascript [英] Disable javascript on mobile websites
本文介绍了在移动网站上停用javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站上有一个聊天小部件,可以在手机上占据整个屏幕。
I have a chat widget on my website which takes up the whole screen on a mobile phone.
如何在一定宽度的设备上禁用聊天设备(或在手机上)?
How do I disable the chat device on devices of a certain width (or on mobile phones)?
<script type="text/javascript">
var _glc = _glc || [];
_glc.push('all_agddsffsd');
var glcpath = (('https:' == document.location.protocol) ? 'https://my.clickdesk.com/clickdesk-ui/browser/'
: 'http://my.clickdesk.com/clickdesk-ui/browser/');
var glcp = (('https:' == document.location.protocol) ? 'https://'
: 'http://');
var glcspt = document.createElement('script');
glcspt.type = 'text/javascript';
glcspt.async = true;
glcspt.src = glcpath + 'livechat-new.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(glcspt, s);
</script>
推荐答案
我可能倾向于限制窗口大小,而不是比设备。
I would probably incline in restricting by window size, rather than device.
function detectmob() {
if(window.innerWidth <= 800 && window.innerHeight <= 600) {
return true;
} else {
return false;
}
}
然后
if(!detectmob()){
//YOUR CHAT CODE
}
这篇关于在移动网站上停用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文