I am interested in developing a bookmarklet that is capable of downloading a remote javascript file containing a defined function, and then executing that function with predetermined parameters.
Below is a typical "download-and-run-remote-script" bookmarklet, but with an additional function call included:
javascript:( function () {
var new_script = document.createElement("script");
new_script.src = "http://mydomain.com/myscript.js";
document.body.appendChild(new_script);
do_stuff('Hello World!');
} ) ();
The code inside myscript.js consists of the following function:
function do_stuff(input_variable) {
alert(input_variable);
}
Currently, this script does not provide the expected outcome. Why is that so? What modifications should be made to make it work as intended?