Re: How to deal with Java Script in None-GUI applications?
Re: How to deal with Java Script in None-GUI applications?
- Subject: Re: How to deal with Java Script in None-GUI applications?
- From: Andrei Tchijov <email@hidden>
- Date: Mon, 30 Jan 2006 13:36:08 -0500
Nicko,
In my case I do not think I need RunningLoop. I am not planing to
use URL Loading System. I think I should be OK with
[WebScriptObject -evaluateWebScript:] and [WebScriptObject -
callWebscriptMethod:WithArguments:]. Something along this line:
WebView* wview = [[ WebView alloc ] initWithFrame: NSMakeRect( 0.0,
0.0, 1.0, 1.0 ) frameName: @"frame" groupName: @"group" ];
WebScriptObject* wso = [ wview windowScriptObject ];
[ wso evaluateWebScript: @"< preamble >" ];
[ wso evaluateWebScript: @"< content of *.PAC file>" ];
NSObject* proxyDefinition = [ wso callWebScriptMethod:
@"FindProxyForURL" withArguments: [ NSArray arrayWithObjects: <url>,
<host>, nil ]];
Andrei
On Jan 30, 2006, at 1:19 PM, Nicko van Someren wrote:
On 30 Jan 2006, at 17:32, Andrei Tchijov wrote:
Nicko,
Thanks for reply. I have tried it already and it does work
wonderfully. And you can get WebScriptObject from WebView. I
guess I need to have more fate into Apple :-).
I'm glad that worked for you.
Just for completeness (for the mailing list archive) it is worth
noting that if you are doing this sort of thing in a command line
tool you are usually still going to need to have a Run Loop running
because the URL loading system makes extensive use of this. I'm
guessing you already had a run loop in play in your program but a
typical simple port of some Unix command line program would not,
and might fall foul as a result.
Nicko
Andrei
On Jan 30, 2006, at 12:25 PM, Nicko van Someren wrote:
On 30 Jan 2006, at 17:05, Andrei Tchijov wrote:
In my application I need to evaluate Java Script ( I need to
extract proxy settings from *.PAC file, which amounts to
invoking Java Script function defined in the file ). The
problem is, that I need to do it in command line tool. There is
no GUI, there is no WebView to which I can send
windowScriptingObject. Documentation for WebScriptObject class
states that it can not be instantiated by itself. Does it mean
that I am stack? Is it possible to get WebScriptObject without
WebView object? Alternatively, is it possible to instantiate
WebView object inside command line tool?
I don't know about creating a WebScriptObject without a WebView
but there is certainly no reason I can think of why you shouldn't
be able to create a WebView without displaying it, e.g.:
WebView wv = [[WebView alloc] initWithFrame: NSMakeRect
(0,0,100,100) frameName: @"Foo" groupName: @"Bar");
[[wv mainFrame] loadHTMLString: someHTML baseURL:
someBaseURL]; // Get your PAC file in here somehow
NSString *request = [NSString stringWithFormat: @"FindProxyForURL
(%@, %@)", urlString, hostString];
theProxy = [wv stringByEvaluatingJavaScriptFromString: request];
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden