开发者

How to make this bookmarklet work on Safari?

开发者 https://www.devze.com 2022-12-20 05:57 出处:网络
I am trying to make a bookmarklet test. Below 开发者_运维问答code works on FireFox but couldn\'t on Safari 4.0.3.

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);
 })();
0

精彩评论

暂无评论...
验证码 换一张
取 消