Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gencon

macrumors newbie
Original poster
Aug 24, 2010
12
0
Hi,

Firstly I hope it's ok to post a WebApp question here, the only dedicated iPhone WebApp forum I could find is very inactive (about 1 post a week).

I've developed an iPhone WebApp which searches a large DVD collection held in a MySQL database. It works well and looks very professional once added to -and launched from- the iPhone's Home Screen with the status bar set to black and the Safari navigation buttons at the bottom gone.

For each DVD on the results page(s), a link is present to load the relevant IMDb (Internet Movie Database) page. This is causing a problem. The initial IMDb page loads in the WebApp but then many (but not all) subsequent links (EG. clicking on the IMDb page's link to 'Full Cast') will open Safari with that page, leaving the WebApp. What I would like is for that to happen immediately, so when clicking on the IMDb link from my WebApp, that immediately opens the link in Safari. Using target="_blank" does not do this. Is there any way I can force the WebApp to open a link in Safari?

Many thanks.
 
I'm not sure i understood fully...

But..
Code:
[[UIApplication sharedApplication] 
openURL:[NSURL URLWithString:@"www.google.com"]];
the code above opens www.google.com in safari.
 
Last edited by a moderator:
But..
Code:
[[UIApplication sharedApplication] 
openURL:[NSURL URLWithString:@"www.google.com"]];
the code above opens www.google.com in safari.
Err no, it is a WebApp, so it's HTML/Javascript, what I need is a way to force a WebApp page to force the iPhone to open a link with Safari.

Is that possible?

Thanks.
 
Last edited by a moderator:
Is your web-app running in a UIWebView?

No. It's just a PHP page added to the iPhone home screen (using Safari's 'Add to home screen' feature) and utilizing meta tags to turn the status bar to black, prevent user zooming, and such like.

Cheers.
 
You're already in Safari mate… Do you mean force it to open in a new "Page/Tab"? I always thought target=_blank worked fine though.
 
You're already in Safari mate…

Well yes and no. If you close the webapp and start Safari, the webapp's page is not shown as one of the Safari pages. Though I take the point that it is an instance of Safari.

Do you mean force it to open in a new "Page/Tab"? I always thought target=_blank worked fine though.

What happens with some links within the webapp - if it moves to a domain other than the webapp's domain - is that some links when pressed will close the webapp and Safari will auto start up showing the page of the link that's just been pressed. It is that behaviour I want to force to happen as soon as the webapp's domain is left by clicking the IMDb link on my results page. Unfortunately "target=_blank" does not make this happen.

Does that make it more clear?

Thanks all.
 
target=_blank not working seems to be a known problem (I did a quick Google search). What happens if you assign a random number to the target? You could do this via Javascript.
 
target=_blank not working seems to be a known problem (I did a quick Google search). What happens if you assign a random number to the target? You could do this via Javascript.
Using Javascript to open the links was a very good idea, it made me try a whole load of different linking methods. I've managed to use a combination of linking types in order to achieve the desired behaviour.

Thanks for your help everyone.
 
Last edited:
Sooo

Can you post what you used? I'm facing a similar dilemma, window.open(url) seems to just go right into the same app and not launch safari...

Thanks!
 
Can you post what you used? I'm facing a similar dilemma, window.open(url) seems to just go right into the same app and not launch safari...

Ok, here is how I ended up getting it to work.

I have 2 ways of specifying a link in the WebApp.

For links that I want to open within the WebApp and not open in Safari, I use this:

Code:
<a onclick="parent.location='http://url.com/page.html'">Link</a>

For links that I want to open in Safari, I use the standard HTML link:

Code:
<a href="http://url.com/another_page.html">Link</a>

That's it. Simple once you know how.

HTH.
 
This is useful information! Thanks!

However, I am looking for a way to do kind of the opposite of this...

From javascript I want to launch a link in Safari without using an <a> tag in the HTML.
I have been using this: window.location.replace (sMyLink);
to launch inside my stand-alone webApp, but have not yet found a way to force sMyLink into Safari.
What I have done is dynamically create a <a> tag for the user to tap inside a custom confirmation dialog. This works, but is not always what I need.

Anyone know how to get javascript running in a stand-alone webApp (launched from the Home Screen and not running inside the actual Safari web browser app) to directly launch Safari with a given link?

Thanks,
-Jeff
 
Anyone know how to get javascript running in a stand-alone webApp (launched from the Home Screen and not running inside the actual Safari web browser app) to directly launch Safari with a given link?


Huh?

You embed it like any other html application.

Code:
<script type="text/javascript">
function helloWorld() {
document.innerHTML = 'Hello World';
}
</script>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.