Search code examples
iphoneipadsafarimobile-safaridashcode

Dashcode Distinguish Between iPad and iPhone Browser


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.


Solution

  • 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"];
    }