I have this bookmarklet, which follows what was proposed in this topic:
javascript: (function () {
var jsCode = document.createElement('script');
jsCode.setAttribute('src', 'http://path/to/external/file.js');
document.body.appendChild(jsCode);
}());
My question is, how can I give the server script some parameter (e.g. page title)?
Server script is the following (just some PoC so far):
(function(message){
alert(message + " " + Math.random()*100);
})();
To pass a parameter to a server-side script, extend the query string:
If you’re intending to pass a parameter to the returned script, add an
onloadhandler to the script element:Response script (file.js):
Update / example
If you want to pass (multiple) variable(s) to your response script, use the following code:
http://path/to/external/file.js: