让这段代码正常工作有些困难。本质上,我想检查引用url是否来自/mobile目录,如果不是,并且屏幕是移动设备,我想重定向到移动站点。
<script type="text/javascript">
if(window.location.href.indexOf("document.write(document.referrer)") > -1 &&
screen.width <= 699) {
document.location = "/mobile/mobile_home.asp";
}
</script>
代码当前放在主home.asp的头部。
发布于 2016-03-23 22:00:13
尝尝这个
if(document.referrer.indexOf('/mobile') > -1 && screen.width < 700) {
}
发布于 2018-08-14 06:38:52
特别是针对indexOf检查,“不相等”也会起作用,而IMHO会让意图更清晰一点。
if ( a.indexOf(somestring) !== -1 ) {
应用于上述示例
if(document.referrer.indexOf('/mobile') !== -1
https://stackoverflow.com/questions/36180212
复制相似问题