When I run this simple greasemonkey script
alert("hello");
alert(document.location);
document.write("hello");
alert("hello");
Only the first two statements work, the third and fourth statement do nothing.
What could be wrong here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It seems that
document.write()only works intermittently from Greasemonkey — maybe due to the sandbox.I haven’t found a foolproof recipe for duplicating the issue yet.
However, the DOM-based approach always seems to work. Use this code:
PS: I updated my other answer as well.