Of course, @bummi, that's a valid point. Below are the JavaScript files mentioned in the link.
I. JS File 1
To add this to your document, create a bookmark with the following URL structure:
javascript:(function(){document.body.appendChild(document.createElement('script')).src='jsFile1.js';})();
The code of jsFile1.js:
Create a variable to hold a new <iframe>
element:
var ifrm = document.createElement("IFRAME");
Specify the page you want to load into the iframe (<iframe>
):
ifrm.setAttribute("src", "http://www.monkeyseatkoalas.blahblah");
Add some style to the iframe:
ifrm.style.width = 100+"%";
ifrm.style.height = 600+"px";
Append the new <iframe>
to the body of the current page. Note: Loading pages in an iframe only works when they belong to the same domain as the parent page.
document.body.appendChild(ifrm);
We now have an iframe on our page with a positional index of [0]. To manipulate this page easily, let's attach another JavaScript file to it using the following code:
frames[0].document.body.appendChild(frames[0].document.createElement('script')).src='jsFile2.js';
II. JS File 2
Ensure everything is loaded before performing any actions to access required elements or perform calculations based on them. You can run the following code once the page is fully loaded:
window.onload = function () { // additional code below...
You can use ".forms" for easy access. For example, assign an ID to a form if it doesn't have one already:
document.forms[numberOfFormElementOnThePage].setAttribute('id', 'mySpecialCupcakeFormCheeseName');
Next, get a reference to the form by its ID:
var getDatForm = document.forms["IDofYourForm"];
Locate and store the input box where you want to enter data. Use the .elements[x] method to access specific elements within the form:
var getDatSearchBox = getDatForm.elements[1];
Prompt the user to provide a search term and store it in a variable:
var nameToFind = prompt('Word to search for? Name? Ice cream? Doggy?');
Update the value of the search box (stored in the variable getDatSearchBox) with the entered text:
getDatSearchBox.value=nameToFind;
Finally, submit the form:
document.forms["users_search"].submit();
};