Drekar
Drekar

Reputation: 51

iPhone Mobile App (safari): which javascript events like onblur, onfocus or onbeforeunload are available?

So I just made my web-application "iPhone Friendly". So you can add it to your home screen and it has an icon, no chroming, etc etc.

The problem is that I want to display a custom splash-screen every time it is opened from the iPhone home screen. Right now it just shows the last screen viewed while it basically runs a refresh.

I have tried attaching events to window.onfocus, window.onblur, window.onbeforeunload, and NONE of them seem to work right when the app is being run in "mobile-app" mode.

Am I being dumb? Er.... don't answer that. Does anyone know what is wrong?

Upvotes: 2

Views: 2070

Answers (4)

Harry Lau
Harry Lau

Reputation: 1

Are you using this?

<meta name="apple-mobile-web-app-capable" content="yes" />

If yes, it should refresh every time when you exit the web app and enter again. It will NOT show the last screen viewed. Hence you can show your splash-screen every time when it is opened. In another words, you should show a full screen div / image every time when you load the page.

Upvotes: 0

Drekar
Drekar

Reputation: 51

Update!! In the iPhone 3.0 update, mobile safari now supports the ability to specify an image to be used on startup:

Remember this only works with iPhones that are running 3.0+

Upvotes: 3

micmcg
micmcg

Reputation: 2390

The loading screen you are talking about is the loading screen for an APPLICATION, not a webpage, i.e its the loading screen for Safari. This has nothing to do with "the restrictions Apple imposes", just with the fact that because your web app still runs in the browser, the browser needs to load first. Like was also said, if you want to get around this you need to build your own app, in which you can specify the splash screen.

Upvotes: 2

Isaac Waller
Isaac Waller

Reputation: 32740

Unfortunately, with the restrictions Apple imposes, this is impossible.
My recommendation is to create a App Store application with a full-screen WebView. Then, you can use a default.png file and a ImageView for your splash screen. Also, you get a ton more visibility on the App Store. (Also, if you go this route, check out PhoneGap - http://phonegap.com/).

Upvotes: 3

Related Questions