Dashcode 区分 iPad 和 iPhone 浏览器

发布于 2024-10-08 04:01:25 字数 818 浏览 0 评论 0 原文

我试图弄清楚如何让 Dashcode Web 应用程序来区分 iPhone 浏览器和 iPad 浏览器。一个有效的示例是 Apple iPad 用户指南。 iPad 将显示一个光滑的破折号内置界面。 iPhone 被重定向到网页。

我在 如何强制 DashCode 问题

我正在编辑redirector.js 文件。下面强制iPad使用由Dashcode构建的Safari布局,而不是Mobile Safari,这正是我想要的。当从 iPhone 浏览时,会返回文件未找到错误。

// redirect to the more appropriate product
if (DCProductURLs["mobileweb"] && DCshowiPhone) {
    // Changed case so that the Safari layout is displayed on iPad
    // window.location.href = DCProductURLs["mobileweb"];
    window.location.href = DCProductURLs["desktop"];
}

感谢您的任何建议。

I am trying to figure out how to get a Dashcode web application to distinguish between an iPhone browser and iPad browser. A working example of this is the Apple iPad User Guide. An iPad will display a slick dashcode built interface. The iPhone gets redirected to a web page.

I found some help in the Howto force DashCode question.

I am editing the redirector.js file. The following forces the iPad to use the Safari layout built by Dashcode instead of Mobile Safari, which is what I want. When it is browsed to from an iPhone, it returns a file not found error.

// redirect to the more appropriate product
if (DCProductURLs["mobileweb"] && DCshowiPhone) {
    // Changed case so that the Safari layout is displayed on iPad
    // window.location.href = DCProductURLs["mobileweb"];
    window.location.href = DCProductURLs["desktop"];
}

Thanks for any suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦萦几度 2024-10-15 04:01:25

测试 window.navigator.userAgent。它将包括 iPad 上的 iPad 或 iPod touch 上的 iPod。

var oniPad = /iPad/.test(window.navigator.userAgent);

Test window.navigator.userAgent. It will include iPad on an iPad or iPod on an iPod touch.

var oniPad = /iPad/.test(window.navigator.userAgent);
亚希 2024-10-15 04:01:25

我最终最终使用了一些基于 ScottRockers 博客上的这篇文章。感谢 ughoavgfhw 让我走上了正确的道路。

if ((navigator.userAgent.indexOf('iPad') != -1)) {
    window.location.href = DCProductURLs["desktop"];
}

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
    window.location.href = DCProductURLs["mobileweb"];
}

I ultimately ended up using some code based on this post at ScottRockers blog. Thanks to ughoavgfhw for putting me on the right track.

if ((navigator.userAgent.indexOf('iPad') != -1)) {
    window.location.href = DCProductURLs["desktop"];
}

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
    window.location.href = DCProductURLs["mobileweb"];
}
尘世孤行 2024-10-15 04:01:25

我修改了我的redirector.js 文件,并且正在做您想要的事情,也许不是最好的方法,但它正在工作,这是我的代码,我希望对您有用:

var DCProductURLs = {
    "mobileweb": "../mobile", 
    "desktop": "../safari"
};

var DCshowiPhone = RegExp(" AppleWebKit/").test(navigator.userAgent) && RegExp(" Mobile/").test(navigator.userAgent);

var DCqs = window.location.search.substring(1);
if ((DCshowiPhone && DCqs.length > 0)||screen.width>1000) {
    var components = DCqs.split("&");
    for (var f = 0; f < components.length; f++) {
        if (components[f] == "p=desktop") {
            DCshowiPhone = false;
            break;
        }
    }
}

// redirect to the more appropriate product
//var device= 
if (DCProductURLs["mobileweb"] && DCshowiPhone && screen.width<=960) {
    window.location.href = DCProductURLs["mobileweb"];
}

I modify my redirector.js file and is doing exactly what you want, maybe is not the best way to do that but it is working, here is my code I hope that works for you:

var DCProductURLs = {
    "mobileweb": "../mobile", 
    "desktop": "../safari"
};

var DCshowiPhone = RegExp(" AppleWebKit/").test(navigator.userAgent) && RegExp(" Mobile/").test(navigator.userAgent);

var DCqs = window.location.search.substring(1);
if ((DCshowiPhone && DCqs.length > 0)||screen.width>1000) {
    var components = DCqs.split("&");
    for (var f = 0; f < components.length; f++) {
        if (components[f] == "p=desktop") {
            DCshowiPhone = false;
            break;
        }
    }
}

// redirect to the more appropriate product
//var device= 
if (DCProductURLs["mobileweb"] && DCshowiPhone && screen.width<=960) {
    window.location.href = DCProductURLs["mobileweb"];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文