I have a UIWebView embedded within an iPhone app I am developing.
I am trying to make the links open in Safari by using target=”_blank” on anchors.
I see that the target property is ignored by the UIWebView, links do not open in a new Safari instance. Why is that?
I know that in order to make this work I have to use shouldStartLoadWithRequest.
You should use
openURLto make Safari open a web page from your app:If you want to “intercept” the tap on a given link and open Safari with that URL, you can use, as you say,
shouldStartLoadWithRequest. I would suggest to use a custom scheme for the protocol of your URL, so you can differentiate links that should open in Safari from links that can be open in yourUIWebView:In this case, you would specify your urls in the HTML page as “safari://…”
Otherwise, simply call
openURLpassing the full URL to it.