Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use the WebKit web inspector from a Cocoa WebView object?

Tags:

cocoa

webkit

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?

like image 885
user53937 Avatar asked Mar 29 '09 17:03

user53937


2 Answers

A REALLY easy way to do it... is in the terminal.... ⌘ ⬆ ☺

defaults write com.yourcompany.yourbundleid WebKitDeveloperExtras TRUE

(With OSX 10.8, use defaults write com.yourcompany.yourbundleid WebKitDeveloperExtras -bool true instead).

NOTE: You MUST change com.yourcompany.yourbundleid to YOUR specific "apps" (or whatever company's app bundle ID it may be) before this will work!**

The nice thing about this... there is NO WAY to forget to take it out, turn it off, comment it out, etc... This is a LOCAL setting... and can be set for ANY webkit enabled app... If you don't see a Developer Menu, or whatnot.. fret not..

Right☝ (click) on the Webview and go to "Show Inspector".

Also, along the same lines, the following may do something as well.. but I havent tried it, so not sure..

defaults write com.yourcompany.yourbundleid IncludeDebugMenu 1

like image 75
Alex Gray Avatar answered Sep 26 '22 01:09

Alex Gray


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.

like image 25
Peter Hosey Avatar answered Sep 24 '22 01:09

Peter Hosey