Infinite Possibilities
Infinite Possibilities

Reputation: 7476

Javascript variable to Applescript

I am using this code:

set javaScriptVar to "var body = document.body, html = document.documentElement; var height = Math.max(body.scrollHeight, body.offsetHeight, html.scrollHeight, html.offsetHeight); return height"

set myJSvar to do JavaScript javaScriptVar in document 1

display alert myJSvar

And the value I am getting is: msng
What's wrong with this?

Upvotes: 1

Views: 721

Answers (1)

adayzdone
adayzdone

Reputation: 11238

Try:

set javaScriptVar to "var body = document.body; html = document.documentElement; var height = Math.max(body.scrollHeight, body.offsetHeight, html.scrollHeight, html.offsetHeight); height;"

tell application "Safari" to set myJSvar to do JavaScript javaScriptVar in document 1

Upvotes: 1

Related Questions