简体   繁体   English

特定页面重定向到相应的移动页面不起作用

[英]specific page redirect to corresponding mobile page not working

I have the following code that works with other circumstances but is giving me problems I guess due to the window.locaton . 我有以下适用于其他情况的代码,但由于window.locaton而给我带来了问题。 Please help I need to redirect users to specific mobile pages depending on the desktop page. 请帮忙,我需要根据桌面页面将用户重定向到特定的移动页面。

 function mon() { if ($('body').is('.mon')) { return true; } else { return false; } } function tue() { if ($('body').is('.tue')) { return true; } else { return false; } } function wed() { if ($('body').is('.wed')) { return true; } else { return false; } } function detectmob() { if (screen.width <= 800) { return true; } else { return false; } } if (detectmob() && mon()) { window.location = "../m/days/mon.html"; } else if (detectmob() && tue()) { window.location = "../m/days/tue.html"; } else if (detectmob() && wed()) { window.location = "../m/days/wed.html"; } 

It was my mistake 这是我的错

 <body class="mon"> <script src="jquip.min.js"></script><!--increase load time instead of jquery.min--> <script> function mon() { if ($('body').is('.mon')) { return true; } else { return false; } } function tue() { if ($('body').is('.tue')) { return true; } else { return false; } } function wed() { if ($('body').is('.wed')) { return true; } else { return false; } } function detectmob() { if (screen.width <= 800) { return true; } else { return false; } } if (detectmob() && mon()) { window.location = "../m/days/mon.html"; } else if (detectmob() && tue()) { window.location = "../m/days/tue.html"; } else if (detectmob() && wed()) { window.location = "../m/days/wed.html"; } </script> 

working fine 工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM