Discussion Forums  >  Uncategorized

Replies: 2    Views: 356

mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
05/09/11 07:45 PM (14 years ago)

open new window in safari

This may be a stupid question but I have many custom html files in my app which look great, but occasionally I have links to other url's that don't look as good (esp with my blue background). Is there a way to format the url that would cause the link to open in safari? I've tried using my html editor (Kompozer) top put open in new window but I think this is javascript and probably not going to work. Any thoughts? I know you guys will be busy tonight with the new updates... no hurry. And thanks for everything!!!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
05/09/11 10:23 PM (14 years ago)
Tougher than it sounds... here's the basic idea: The idea is that you 'trap' or 'detect' the link that was clicked. Then, based on what you learn about the link, you either continue loading the webpage it linked to, or, stop and do something else. To do this you format the html links in a way that will allow you to 'detect' them when they are clicked. For every click, some UIWebViewDelegate methods are called. In this case, you'll want to pay special attention to the shouldStartLoadWithRequest method. Have a look at that method in the BT_screenCustomURL.m or BT_screenCustomHTML.m files in the project download. Take some time to review that method. You'll see where some information about 'what was clicked' is being processed. Example...if the link that was clicked had a URl (href) that includes a Google Maps url, it wont' load but instead fire another method to ask the user if they want to open the native maps app. So.... in order for you to customize the behavior of an HTML link, you'll need to first create some links that are 'different' than the other links. Then, when one of these links is clicked, you can catch it in the shouldStartLoadWithRequest, stop the processing of the web-view, then trigger some other event - like a custom playMyVideo method, launch Safari, or whatever. See if you can get this far then nudge this thread if you get somewhere...or get stuck... of course Google's pretty smart too. Try a Google search for Call Objective C method from HTML for dozens of tips, articles, etc.
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
05/10/11 02:55 AM (14 years ago)
Thanks!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.