Dashcode distinguishes between iPad and iPhone Browser

I'm trying to figure out how to get a Dashcode web application to distinguish between iPhone browser and iPad browser. A working example of this is the Apple iPad User Guide . The iPad will display a sleek built-in dashcode interface. IPhone is redirected to the web page.

I found some help in the Howto force DashCode question .

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

// 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.

+3
3

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

Test window.navigator.userAgent. iPad iPad iPod iPod touch.

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

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

Source: https://habr.com/ru/post/1780928/


All Articles