Re: Safari "do javascript" busted?
Re: Safari "do javascript" busted?
- Subject: Re: Safari "do javascript" busted?
- From: Daniel Jalkut <email@hidden>
- Date: Mon, 25 Apr 2005 20:50:47 -0700
Hi - I saw a similar problem discussed on the macscript mailing list.
In response to that issue I tinkered a bit and discovered that
modifying the javascript to use "unescape(getSelection())" instead of
"getSelection()" seems to work around the problem.
For some reason Safari seems willing to return the text from unescape
but not from getSelection() directly.
Hope this helps,
Daniel
On Apr 25, 2005, at 12:07 PM, Richard Brosnahan wrote:
Thanks Darren,
I did nearly what you said, but I had to add a couple lines to deal
with clobbering the clipboard. As you know, there are some
advantages to not borrowing the clipboard. It's also better to ask
the application directly for the data rather than dealing with UI
commands. UI commands are not all that reliable.
The fix you suggested works fine, so I'll deal.
Thx again
--
Richard Brosnahan
Editor in Chief
Broz News
http://broznews.org
Forever is composed of nows.
Emily Dickinson, poet
On Apr 25, 2005, at 2:30 PM, applescript-users-
email@hidden wrote:
Hi Richard-
A bit behind in reading the digest version of the list, but I
didn't D
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40red-sweater.com
This email sent to email@hidden
_______________________________________________
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