[webkit-dev] How to catch JS exceptions/log messages from a WebView?

Kevin Decker kdecker at apple.com
Sat Dec 22 09:49:45 PST 2007

On Dec 22, 2007, at 8:14 AM, Todd Ditchendorf wrote:

> In a Cocoa app which embeds a WebView, what is the best way to catch  
> all JS exceptions from the WebView which are thrown and are not  
> caught within JS itself?
> For example, I want to implement something similar to the JavaScript  
> Console in the Safari debug menu.
> Also, how do you capture statements sent to console.log(),  
> console.warn() and console.error() within a WebView?

Hey Todd.  There's no public WebKit API for this, but if you look in  
WebUIDelegatePrivate.h you'll see the following method:

- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary  

The dictionary currently contains a source URL, error message and line  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20071222/4b7823bd/attachment.html

More information about the webkit-dev mailing list