tes*_*123 2 javascript if-statement indexof
在使用此代码时遇到一些困难.基本上,我想检查引用的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>
Run Code Online (Sandbox Code Playgroud)
代码目前放在主要的home.asp的头部.
试试这个
if(document.referrer.indexOf('/mobile') > -1 && screen.width < 700) {
}
Run Code Online (Sandbox Code Playgroud)