Reputation: 55
Buttons in webpages have a disabled status. This status can be true or false. if true, that means the button is greyed out on the webpage.
With Javascript, I can retrieve the status with this:
document.getElementById('view-more').disabled
it will either return true or false.
But if I combine this with AppleScript:
set buttonStatus to do Javascript "document.getElementById('view-more').disabled
Nothing gets returned about the status of the button.
The actual HTML code for the button is:
<button id="view-more" class="view_more">View more</button>
And when the button is disabled it becomes:
<button id="view-more" class="view_more" disabled="disabled">View more</button>
Upvotes: 0
Views: 173
Reputation: 7555
Using a simple HTML file with a disabled button, the following example AppleScript code works for me:
Example AppleScript code:
tell application "Safari"
do JavaScript "document.getElementById('button').disabled;" in document 1
end tell
The contents of the HTML file as shown in Terminal:
% cat button.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button id="button" disabled>Button</button>
</body>
</html>
%
Screen Shot of Script Editor:
With the button enabled.
The contents of the HTML file as shown in Terminal:
% cat button.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button id="button">Button</button>
</body>
</html>
%
Screen Shot of Script Editor:
Upvotes: 1