I developed a small web app which runs perfectly in my browsers (Firefox, Chrome, Safari on iPad). Then I decided to modify the app so it runs as a standalone web app on my iPad. This was no problem as I found pretty good information on the web.
Because I'm using many app-internal links, I added the following JavaScript jQuery code to the app:
if (window.navigator.standalone) {
// running as web app
$(function () {
$('a').each(function () {
if (!$(this).hasClass('external')) {
var href = $(this).attr('href');
$(this).attr('href', 'javascript:this.location = \'' + href + '\'');
}
});
});
}
In case the app is run in standalone mode, this code modifies all links which do not have the CSS class external
so they won't open in a new Safari window. This code works fine.
The problem is that if I open a link that is external, a new Safari window opens (as expected). But when I switch back to my app (using the four-finger-gesture), the app is frozen: No scrolling, nothing clickable, no task switching, no five-finger-gesture anymore. When I press the Home button, the iPad shows my home screen for a split second, and then instantly switches to the iPad search screen. When I turn the screen off and on again, I'm on the home screen.
The only gesture that works is the four-finger-gesture to bring up the task bar (is that its name?). When I terminate the app using the task bar, it is still on the screen and the iPad behaves as if I hadn't terminated the app (see last paragraph). Feels like the app crahed in some crazy way.
I don't know what I've done wrong. It's a pretty simple web page with very few JavaScript and an HTML structure that is not deeply nested.
The device is an iPad 2 3G with iOS 5.1.
Can anyone help me with this?