开发者

Bookmarklet to open an empty tab/window with some javascript in it?

I know there are a lot of discussions about opening http pages in new windows and tabs,

but that's not what i'm looking for.

How do I open an empty new tab an开发者_StackOverflow中文版d run some arbitrary js in it?

That is when someone clicks my bookmarklet, a new tab should appear and code such as "document.write(foo)" should run in it with foo coming from the js on the tab where bookmarklet was clicked on.


This bookmarklet is the translation of your question:

javascript:void(function(foo){
    var d=window.open("");
    d.document.open();
    d.document.write(foo);
    d.document.close();
})("Foo")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜