Selected Text in Safari into a Variable?


is it possible to put the sected text of a homepage in safari in a variable usin Applescript?

Thank you for your help


activate application "Safari"
tell application "System Events" to tell process "Safari" to keystroke "c" using {command down}
set myGrab to the clipboard

…or with Javascript

tell application "Safari" to set selectedText to (do JavaScript "\"\"+window.getSelection();" in front document)

Thank you for that, Stefan - I can never remember the JavaScript syntax. :confused: