I am storing text from TextEdit in an AppleScript variable, and I want to pass it to JavaScript. I thought I was doing it right, but I still can't get the value to be stored. The code is as follows:
tell application "TextEdit"
activate
set docText to the text of the front document --This works. I've checked.
end tell
tell application "Google Chrome"
tell window 1
tell active tab
execute javascript "function encryptDocument() {
plainText = '" & docText & "';
return plainText;
} encryptDocument();"
set skurp to the result
display dialog skurp
end tell
end tell
end tell
The reason I house the JavaScript code within a tell application "Google Chrome"
command is because I get an error every time I try to call it in the previous tell application "TextEdit"
command. The error always says that it expects an end of line but found "
. Not really sure why, but I can't find a way around this problem.