• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting selection in Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >getting selection in Safari (From: Dan Feather <email@hidden>)

  • Prev by Date: Re: getting selection in Safari
  • Next by Date: Q: GraphicsConverter Paste At (format for position?)
  • Previous by thread: Re: getting selection in Safari
  • Next by thread: Q: GraphicsConverter Paste At (format for position?)
  • Index(es):
    • Date
    • Thread