View Full Version : Open Safari from a Application
satyam90
Oct 19, 2007, 07:57 AM
Hi,
In my application I am providing a html file.
I am having a button in my dialog. On clicking that buton, i want to show the html file in Safari (or any other browser that is available). How to do this.
Regards,
Satyam.
hhas
Oct 19, 2007, 08:44 AM
If it's a help file, don't forget that OS X provides a standard framework for dealing with those. Otherwise, you could use something like the following, which will open a resource file using the default application for that file type:
NSString *path = [[NSBundle mainBundle] pathForResource: @"yourfile" ofType: @"html"];
BOOL success = [[NSWorkspace sharedWorkspace] openFile: path];
garethlewis2
Oct 19, 2007, 08:48 AM
You could use an Applescript to open Safari and then display the file in question.
Other options include using fork and exec.
Using 'system'
Using NSTask.
kainjow
Oct 19, 2007, 10:50 AM
You could use an Applescript to open Safari and then display the file in question.
Other options include using fork and exec.
Using 'system'
Using NSTask.
There's also Launch Services (http://developer.apple.com/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCIntro/chapter_1_section_1.html)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.