Re: getting selection in Safari
Re: getting selection in Safari
- Subject: Re: getting selection in Safari
- From: Timothy Bates <email@hidden>
- Date: Tue, 31 Jan 2006 12:11:57 +0000
- Thread-topic: getting selection in Safari
Following feedback from the safari bugzilla:
Safari 1.2 had a bug (feature?) of returning strings, not objects.
Safari 1.3 returns the object, which you can't handle in AppleScript
So... For 1.3 onward, you need to coerce the object to string in Jscript
do JavaScript "getSelection().toString()" in document 1
Selection:toString() didn't always work, so to be backward compatible, use
tell application "Safari"
do JavaScript "getSelection() + \"\"" in document 1
end
That's just like AppleScript, where adding a string to an object coerces
things down to that level.
I made a handler to call:
getSelection(1)
to getSelection( winNum)
tell application "Safari"
return do JavaScript "getSelection() + \"\"" in document winNum
end tell
end getSelection
> Excuse my ignorance, but is it possible that one cannot get a reference to
> the selection in Safari? I can hardly believe it.
> TIA,
_______________________________________________
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