Re: Safari "do javascript" busted?
Re: Safari "do javascript" busted?
- Subject: Re: Safari "do javascript" busted?
- From: "D. Mahaffy" <email@hidden>
- Date: Mon, 25 Apr 2005 00:03:13 -0400
Hi Richard-
A bit behind in reading the digest version of the list, but I didn't see any responses to your query so I thought I'd chime in.
I've also had issue with "getSelection()" with Safari 1.3. It flat-out doesn't work. Don't know if syntax has changed or not, perhaps others who know more have the answer.
My solution was to alter my script with the following (removing the entire do JavaScript section) not sure it'll work in your situation, but here goes:
tell application "Safari"
activate
--
set clipText to (do JavaScript "getSelection()" in document 1) as string
tell application "System Events"
to keystroke "c"
using {
command down}
delay 0.5
set clipText to (
the clipboard)
as text
end tell
You would simply replace "clipText" with "pTheStory". Unfortunately, if you have stuff on the clipboard, it'll be replaced whereas that wasn't an issue with "do JavaScript". Haven't seen a lot of chatter on this topic anywhere. Then again, I've not dug too deeply. Hope it gets resolved soon, and I hope this is helpful to you.
--
Best,
Darren
MacSurfer
On Apr 19, 2005, at 3:21 AM, email@hidden wrote:
5. Safari "do javascript" busted? (Richard Brosnahan)
Message: 5
Date: Mon, 18 Apr 2005 17:31:32 -0400
From: Richard Brosnahan <email@hidden>
Subject: Safari "do javascript" busted?
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed
I have a script embedded in an AppleScript Studio app that has been
working properly for quite awhile. I updated my OS to 10.3.9, and now
my calls to Safari using the do javaScript command fail to return any
values. Executing these same javascripts within the browser work just
fine. One in particular is just dirt simple, yet does not work any
more.
tell application "Safari"
set pTheStory to do JavaScript "getSelection();" in document 1
end tell
fails to set pTheStory to any value whatsoever.
Can anyone provide some advice?
TIA
--
Richard Brosnahan
Editor in Chief
Broz News
http://broznews.org
I love the man who can smile in trouble, who can gather strength from
distress, and grow brave by reflection.
Thomas Paine, statesman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden