Let’s look at it more carefully. If we assume that the page has a:
- Textbox with ID ‘UserName’.
- Textbox with ID ‘Password’.
- Form submit button.
So, when I click on the browser bookmark, the script will:
- Populate ‘UserName’ control with ‘a_user’.
- Populate ‘Password’ control with ‘their_password’.
- Submit the form.
As an esteemed colleague quite rightly pointed out, the code makes two important assumptions:
- You are using jQuery
- The fields have IDs
If you’re not using jQuery, then simply using document.getElementById will suffice. There are also ways of getting elements without IDs, but if you do have control over the HTML then I would suggest adding them in anyway.