我正在尝试让我的在线帮助重定向到手机版本。但是,我是从单一来源生成手机和桌面版本的,所以我想要一段代码来完成这一切(手机 <-769-> 桌面)。由于大小发生使用,我得到了重定向:
if (screen.width <= 769 || windowWidth <= 769) {
window.location = "../phone/Selecting_a_School_Register.htm";
但是当我在电话页面上时,它一直在尝试加载页面(我明白为什么)。我自己尝试过,但我对此并不陌生,这是我的(失败的)尝试:
windowWidth = window.innerWidth;
<!--
if (location.pathname = "/desktop/Selecting_a_School_Register.htm";)
{
} else if (screen.width <= 769 || windowWidth <= 769) {
window.location = "../phone/Selecting_a_School_Register.htm";
}
</script><script>
if (location.pathname = "/phone/Selecting_a_School_Register.htm";)
{
} else if (screen.width >= 769 || windowWidth >= 769) {
window.location = "../desktop/Selecting_a_School_Register.htm";
}