Some developments regarding this. I use -loadRequest to obtain a
local html file that reads:
<html>
<head>
<SCRIPT type="text/javascript"><!--
function cocoacalling(scrObject)
{ scrObject.Score = 1000; document.write('cocoacalling'); return
scrObject.Score;}
// -->
</SCRIPT>
</head>
<body>foo</body>
</html>
in -didFinishLoadForFrame:
result = [wso callWebScriptMethod:@"cocoacalling" withArguments:args];
NSLog(@"%@ result", result);
returns me '1000 result'
so far so good.
using an action method, I initiate:
[[(DOMHTMLElement *)[[[webView mainFrame] DOMDocument]
documentElement] outerHTML] writeToFile:@"/Users/mhanna/myDev/
GetActualJavascriptWorking/DataTypeRoot.keyaccess/domhtml.html"
atomically:YES];
the contents of the file domhtml.html:
<HTML></HTML>
seems that [(DOMHTMLElement *)[[[webView mainFrame] DOMDocument]
documentElement] outerHTML] writes an empty HTML container(hence, I
get a (null) result). I swear it was printing the full DOM
yesterday..! Got any ideas on getting the right DOM?
You might as well log wso at the time as well, just for sanity's sake.
how do I do this? [wso description] ?
I have -awakeFromNib:
Class webCoreJavaScript = nil;
if ((webCoreJavaScript = NSClassFromString(@"WebCoreJavaScript")))
{
if([webCoreJavaScript respondsToSelector:@selector
(setShouldPrintExceptions:)])
[webCoreJavaScript setShouldPrintExceptions:YES];
else
NSLog(@"Can't log JS Exceptions");
}
but this just logs exceptions.
BTW, in the original HTML, document.write('cocoacalling'); doesn't
write to the WebView. Any idea why, even though the script seemed to
return the proper value anyway?
Michael
--
Michael Hanna
email@hidden
iChat: michaelkhanna(AIM)
On 2-Dec-05, at 3:58 PM, Geoffrey Garen wrote:
Calling setValue:forKey: on wso sets a value in the window object.
It's like having the line "scrObject = XXX" inside a <script> tag.
However, you pass scrObject directly as an argument to cocoacalling
(), so setting the value of scrObject globally is superfluous.
I don't understand this comment. In the example you provide, the
JavaScript gets created through the following line:
You might as well log wso at the time as well, just for sanity's sake.
Is this a typo? I thought the loadHTMLString case did not return a
value.
As for loadRequest, that is indeed strange.
Seems like a reasonable work-around, but I'd prefer to get to the
bottom of the problem.
Geoff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden