I would like to use the WebKit web inspector in a custom browser based on WebKit on OS X. Is it possible to use the web inspector on a webview object? If so, how?
views:
523answers:
2
+4
A:
Set WebKitDeveloperExtras
to YES
in your default user defaults when you send -[NSUserDefaults registerDefaults:]
. This applies app-wide, of course.
Remember that the user can change it to NO
, so don't assume that it's YES
—if it ever matters (e.g., when customizing the contextual menu), always check.
Warning: This preference doesn't necessarily only enable the Element Inspector. Apple may extend it in the future to also control, say, a Debug menu in your menu bar. You may find this an unacceptable risk.
Peter Hosey
2009-03-29 18:21:27
This works! Awesome! Side note: It sets the setting on the first load, which doesn't take effect until the app is restarted. Not sure how to get around this -- perhaps supply a default properties file...
2009-03-30 02:21:21
loglibrarian: Set it earlier. If applicationWillFinishLaunching: isn't good enough, set it in your main() function.
Peter Hosey
2009-03-30 06:29:39
Ok I know I'm pushing my luck here, but is there a way to programatically launch the web inspector? Perhaps a private api?
2009-03-30 16:49:36
Private API is private because it will go away someday. (Or become public with no changes, if you're EXTREMELY lucky.) If you're feeling bold, class-dump WebKit and try using the WebInspectorWindowController. Be sure you guard everything so that you fail gracefully if it changes.
Peter Hosey
2009-03-30 17:35:34
A:
I tried doing so, but couldn't see WebInspector. Isn't it like ][NSUserDefaults standarduserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"WebKitDeveloperExtras"]]?
JongAm Park
2009-12-09 17:34:44
Thanks. From webkit-dev mailing list I received another response.It should be done in its earliest moment like +initialize, or it can be issued on Unix prompt.defaults write com.yourcompany.programname WebKitDeveloperExtras -bool true
JongAm Park
2009-12-10 18:35:00