To document web pages using Safari + Applescript and Filemaker pro 8 Advanced
I am building some routines, including this one:
==== my test script
tell application “Safari”
set the_title to name of window 1 as string
set the_URL to URL of document 1 as string
end tell
set quote_text to “ " & the_title & " ” & return & “ " & the_URL & " ” & return & “ "
tell application “Safari” to set the clipboard to quote_text & (do JavaScript “window.getSelection()+‘’;” in document 1) & " ”
=== en my test script ===
The problem maker was some changes that made the javascript get Selection not react
I did found a workaround at
http://joemaller.com/2005/04/24/getselection-workaround/#comments
which is adding an empty string <‘’> to the argument.
“window.getSelection()+‘’;”
This works somehow… BUT
the text string is somehow odd… different from what one would get with copying the same selected areqa on a web page
The difference is that whole series of spaces are in the text and that certain lay-out elements of a web page generate (invisible) ASCII (a n upside down ? question mark.
As I am entering the text string in Filemaker pro I have written some stripping routine to get these unwanted text elements out.
But I am almost sure that it is my lack of knowledge of javascript text strings returned from a web browser that may make this stripping routine necessary, and that other more elegant solutions may exist.
I will be grateful for any suggestion
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)