<textarea cols="30" rows= "5" name="name" id="id" class="class">This is it!</textarea>
tell application "Safari"
tell document 1
set byName to do _javascript_ "document.getElementsByName('name')[0].value"
set byTagName to do _javascript_ "document.getElementsByTagName('textarea')[0].value"
set byID to do _javascript_ "document.getElementById('id').value"
set byClassName to do _javascript_ "document.getElementsByClassName('class')[0].value"
end tell
display dialog byName with title "byName"
display dialog byTagName with title "byTagName"
display dialog byID with title "byID"
display dialog byClassName with title "byClassName"
end tell
tell application "Safari"
tell document 1
set byFunction to do _javascript_ "
function findTextArea() {
var i, textAreas;
textAreas = document.getElementsByTagName('textarea');
for (i=0; i<textAreas.length; i++) {
if (textAreas[i].name == 'name') {
return textAreas[i].value;
}
}
}
findTextArea();"
end tell
display dialog byFunction with title "byFunction"
end tell
---------------
All of the cases in the script will display the contents of the text area as specified in the original HTML. The also will display the contents of the modified text if I manually change the contents of the text area by typing a new value into is.
Thanks again,
Jerry