For a minute there I thought you were asking the same question again as last time.
But realise now you want to know how to use Inspect Element to construct your own code.
In the example you give: document.forms[WHATGOESHERE?].click()
The WHATGOESHERE would be the form name.
i.e document.forms['theFormName'].click()
Your website in their wisdom has named the form 'form'
<form method="post" action="/cgi-bin/RNAfold.cgi" enctype="multipart/form-data" name="form">
<input type="hidden" name="PAGE" value="2">
i.e document.forms['form'].click()
But this would not click the input button
You can use the submit() function dot syntax'd on the end :
document.forms['form'].submit()
Safari Applescript : do JavaScript "document.forms['form'].submit()"
Also
In the code I provided you in your last question. I used:
tell document 1
do JavaScript "document.getElementsByClassName('proceed')[0].click()"
end tell
This uses the class Name proceed of the forms input element seen here: class="proceed"
<input value="" name="proceed" type="submit" class="proceed" onmouseover="this.style.cursor="pointer"" style="cursor: pointer;">
The getElementsByClassName('proceed')[0]
does exactly what it says.
It gets the Elements By ClassName 'proceed'.
The [0] means it will give you the first element in it's results from the Array that would be returned. The array is counted from 0-9. So the first item would be item 0.
A good place to get working examples and information about Javascript is at www.w3schools.com On the front page the have links to their HTML and Javascript examples and Tutorials. The elements of the HTML Dom and Javascript functions are listed for easy access.
1 - Run Disk Utility from the Utilities folder and "Repair Permissions." Let it run. It will take a while. When it is done, quit the program.
2 - Reinstall an anti-virus program and run a scan.
3 - Open Safari and from the "Safari" menu, click on reset Safari.
4 - Go to System Preferences, click on "Security and Privacy." Make sure your firewall is set to "ON."
Best Answer
As an example in Google Chrome, using the URL of this question and setting the scroll to point to the question header of the page, use Chrome > View > Developer > Developer Tools ⌥⌘I to find the
id
. In this case it's calledquestion-header
.You can also right-click and select Inspect from the context menu, which will bring up Developer Tools directly to that point in the code.
The following code will open this page and scroll to the question header.
You can see in the code above that
question-header
was swapped fortwc-scrollabe
in theexecute javascript ...
line of code.You can also get a quick list of the
<div id=
anchor points usingcurl
in Terminal and piping the output togrep
, as in the example for this page.Note: While
curl
will bring the page down, thegrep
command as shown in the example may not work as nice as it did for this page. Some page content doesn't have line breaks and the code is a contiguous stream.