0
現在,如果您在移動設備上訪問我的網站,您將被重定向到一個子域,這要歸功於以下代碼。其中檢查您的屏幕寬度是否低於800或如果你在iphone,ipad或ipod。允許移動設備重定向或查看完整網站
我希望能夠做的一件事是允許訪問者查看完整的網站,如果他們想。如果他們選擇這樣做,我該如何讓他們繞過這一切?
<script type="text/javascript">
<!--
if (screen.width <= 800) {
document.location = "http://m.site.ca";
}
//-->
</script>
<script type="text/javascript">
// <![CDATA[
if ((navigator.userAgent.indexOf('iPhone') != -1) ||
(navigator.userAgent.indexOf('iPod') != -1) ||
(navigator.userAgent.indexOf('iPad') != -1)) {
document.location = "http://m.site.ca";
} // ]]>
</script>
你可以使用[確認對話框](https://developer.mozilla.org/en-US/docs/Web/API/Window.confirm) - 與cookie的想法相結合,使用戶不會每次訪問新頁面時都必須確認他們想要查看哪個網站。您可能還想通過[使用此]檢查移動設備(http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-handheld-device-in-jquery )而不是檢查屏幕寬度 – Pete