Running JavaScript via AppleScript Problems
Running JavaScript via AppleScript Problems
- Subject: Running JavaScript via AppleScript Problems
- From: Mark Thomas <email@hidden>
- Date: Fri, 17 Nov 2006 18:30:42 +0000
- Organization: Coderus Ltd
Hi All,
I'm trying this question on WebKit lists, but wondered if anybody here
might have had a similar problem when trying to pass encoded characters ?
Thanks
Mark.
----------------------------
Hi,
I'm trying to run some and all works fine if I'm using
stringByEvaluatingJavaScriptFromString, but I'm seeing a problem when I'm
trying to use Apple Script Component.
All work's fine, when I'm trying not to return any data to a JavaScript
function which doesn't need to use \ notation to encode certain characters.
As the Apple Script code is
(gdb) print scriptText
$1 = 0x5bcd10 "tell application \"Safari\"\n do JavaScript \"var where; if
(typeof(IBISmain)!='undefined') where=IBISmain; else where=window;
where.onStatusDone(0, 'my result is \\\"Yes\\\" \\\n.');\" in document 1\n
end tell"
Will happy run pass and no error is returned by OSADoScript, but Safari
doesn't do anything, if I take out the so my call is onStatusDone (0,
'hello' ); then my JavaScript within Safari is executed fine.
So I thought that maybe I have too many \ characters in supplied script
(but above Script works fine via the stringByEvaluatingJavaScriptFromString
ok without the tell phase around it) and had it as
(gdb) print scriptText
$1 = 0x5bca90 "tell application \"Safari\"\n do JavaScript \"var where; if
(typeof(IBISmain)!='undefined') where=IBISmain; else where=window;
where.onStatusDone(0, 'my result is \"Yes\" \n.');\" in document 1\n end
tell"
This will cause a -1753 (errOSAScriptError) from OSADoScript, which is why
I added more \ characters. Which I kindya expected.
To create the AE event and executing is
result = AECreateDesc(typeChar, scriptText, theSize, &scriptSource);
result = OSADoScript( sScriptingComponent, &scriptSource, kOSANullScript,
typeChar, kOSAModeCanInteract, &resultAE );
Does anybody have any thought on why Safari isn't running the JavaScript on
the first try as OSADoScript returned noErr.
Thanks
Mark.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden