How to make this bookmarklet work on Safari?
I am trying to make a bookmarklet test. Below 开发者_运维问答code works on FireFox but couldn't on Safari 4.0.3. Does anybody know how to make it work on Safari?
javascript:var s = document.createElement("script");
s.text = "document.write('hello');";
s.type = "text/javascript";
document.body.appendChild(s);
Try with: s.innerHTML = "document.write('hello');";
You need to add document.close() after document.write(...);
javascript:(function(){
s=document.createElement("script");
s.type="text/javascript";s.text="document.write('Hello88');document.close();"
document.body.appendChild(s);
})();
精彩评论