• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."


  • Subject: Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
  • From: Roger Howard <email@hidden>
  • Date: Tue, 20 Oct 2009 14:55:28 -0700


On Oct 20, 2009, at 2:43 PM, Mark J. Reed wrote:

Never.  The initial contents only appear because they're part of the
HTML source of the page.  To get changes after the page is loaded,
you'll have to use JavaScript.

A web page is an in-memory object tree that is initialized from the
HTML, but not maintained in HTML form when it changes.

Ahhh, just beat me to it. What Mark said...

HOWEVER - it is possible to get the *current* contents of a text field via the "do JavaScript" command in Safari... this is reaching into the in-memory state of the page to inspect (and even modify) the state of the DOM.

For instance, the following AppleScript+JavaScript snippet will get the contents of a textarea whose name is "sometext" within a form named "someform" and put it in an AppleScript variable named theTextAreaValue.

-----------

tell application "Safari"
tell document 1
set theTextAreaValue to do JavaScript "document.someform.sometext.value"
end tell
end tell


-----------

HTH,

Roger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Safari: When do changes to a <textarea> show up in AppleScript "get the text..." (From: email@hidden)
 >Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..." (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: 64 vs 32
  • Next by Date: Re: 64 vs 32
  • Previous by thread: Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
  • Next by thread: Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
  • Index(es):
    • Date
    • Thread