Totally newbie about JS.
I need to use an external script which modifies some elements in the current page accessing it as a bookmarklet.
If I modify the html source code of the web page inserting the following < script > lines:
s=document.createElement('script');
s.type='text/javascript';
s.src='script.js';
document.getElementsByTagName('head')[0].appendChild(s);
it works fine. But if I create a javascript: bookmarklet with the same lines, I obtain a blank page with the following string:
[object HTMLScriptElement]
whereas, if I create a bookmarklet adding the line
void(null);
to previous ones, the web page does not disapper but the script is not executed.
Why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…