Workaround for a Safari 1.3 getSelection() problem

Apr 26, '05 07:42:00AM

Contributed by: redsweater

Safari 1.3 breaks AppleScripts that rely on the value of getSelection() from a do JavaScript call in Safari:

tell application "Safari"
  do JavaScript "getSelection()" in document 1
end tell
I discovered that by introducing another functional call around getSelection, Safari is coerced into returning the string as expected. There may be many possible calls that will fix this, but unescape() seems the most innocuous:
tell application "Safari"
  do JavaScript "unescape(getSelection())" in document 1
end tell
[robg adds: I haven't tested this one...]

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050422144207644