• 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: "Mark J. Reed" <email@hidden>
  • Date: Tue, 20 Oct 2009 18:19:42 -0400

Or if the textarea has an id="someid" attribute, Yup, that's what I
had in mind when I said you'd have to use JavaScript.

A couple alternatives for finding the textarea from JavaScript.
First, if it has an id="someid" attribute, this will work no matter
where it is:

"document.getElementById('someid').value"

Second, if it's the only textarea on the page:

"document.getElementsByTagName('textarea')[0].value"




On Tuesday, October 20, 2009, Roger Howard <email@hidden> wrote:
>
> 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
>

--
Mark J. Reed <email@hidden>
 _______________________________________________
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: Roger Howard <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>)
 >Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..." (From: Roger Howard <email@hidden>)

  • Prev by Date: Re: 64 vs 32
  • Next by Date: Re: Safari: When do changes to a <textarea> show up in AppleScript "get the text..."
  • 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