Re: Intercepting JavaScript calls in WebViews
Re: Intercepting JavaScript calls in WebViews
- Subject: Re: Intercepting JavaScript calls in WebViews
- From: Jonathan Wight <email@hidden>
- Date: Sun, 14 Dec 2003 17:47:49 -0600
The easiest solution is a pure JavaScript one - but this depends on you
controlling the content: replace 'javascript:function(parameter)' with
something like 'javascript:'myintelligentfunction(function,
parameter)'.
Another way (again if you control the content) then you can replace the
'javascript' URL scheme with something else ('x-javascript' for
example) then register your own NSURLProtocol (and maybe an NSURLHandle
depending on your needs) in which you do do your magic and pass it on
to stringByEvaluatingJavaScriptFromString.
Yet another option would be to execute JavaScript when every page loads
(use the right WebKit delegate for that - I've had to do this to load
support .js code for every page) that replaces function in the
javascript globals with your 'intelligent' function. But then you need
to patch every function that might be called from your content - this
may or may not be feasible.
The last method I can think of involves hacking JavaScriptCore (Apple
provides the source) and forcing WebKit to use your hacked
JavaScriptCore instead of the systems. This is possible but has many
problems associated with it.
Good luck.
Jon.
On Dec 14, 2003, at 14:55, Patrick Machielse wrote:
>
Hi,
>
>
I'm working on a project using a WebView. The html that is displayed
>
contains JavaSctipt links like:
>
>
<a href="javascript:function(parameter);">click me</a>
>
>
When the user clicks on a link, I must intercept the JavaScript
>
function
>
call (which is implemented as an empty function in the html) and do
>
something intelligent with the function parameter.
>
>
Is this possible in WebKit? I tried overriding WebView's
>
>
stringByEvaluatingJavaScriptFromString:
>
>
method, but that doesn't seem to get called by WebView itself...
>
>
- Is what I wan't possible at all using webkit?
>
- Does anyone know of a method to find out which element of a web page
>
was clicked?
>
- Can I get access to the elements displayed in a WebView / WebFrame?
>
>
>
Groeten,
>
>
Patrick
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.