views:

423

answers:

2

Easy enough to register a custom protocol handler so that a native app gets launched by a URL in Safari. However, doing this leaves the current browser window open. If the app then provides a link back to a URL (via openURL), that url will open in a new Safari window, ignoring the existing window. I asked a question here about loading in the same window, and it was suggested that using #anchor tags to differentiate content but using the identical url would confuse Safari into reusing a window, but that isn't true. Safari launches a new window even when the URLs are absolutely identical, including the #anchor tag. My next thought was to close the window via window.close() javascript before opening the url for the native app. But I can't get it to work. If I use an ajax call for the url, it doesn't actually launch the native app. If I use window.open(url), it cancels the closing of the prior window, whether I open the url before or after calling window.close().

Does anyone know of a way to get the current Safari window to close before launching a native app via a URL?

+1  A: 

I don't believe this is possible, although I may be proven wrong.

chpwn
A: 

Since the safari browser in iphone does not fully suppor the javascript execution , its not possible.

Else if u want to do for the PC / Mac system it is possible using javascript code

Hint: call a javascript method on clicking the url.In that method create a new instance of the window to open using window.open, and finally close the parent window using self.close(); or window.close();

Biranchi