I am trying to load up 2 different pages depending on what apple device I am using. I am doing this by checking the width of the device and then loading up 1 of 2 pages, my code is:
JavaScript:
function init()
{
if (screen.width <500)
{
window.open("home_phone.html");
}
else if (screen.width>=500)
{
window.open("home_iPad.html");
}
}
HTML:
<body onLoad="init();">
</body>
This should essentially load up 2 dfferent home pages. However for some reason it does not. It runs the function (tested using alerts), however does not load the page.
I then when on to test the function itself by adding a link which referred to the same init() function and the link worked fine.
Any ideas how i can get this to load up on the intial page load.
Thanks.
For me your code works if I use
window.location=instead ofwindow.open().I don’t know if that is acceptable for you, but your code would then look like this:
I hope this works for you. (If not try eventually another browser like Firefox or Chrome.)