开发者

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

开发者 https://www.devze.com 2023-04-11 12:04 出处:网络
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.

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

精彩评论

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

关注公众号