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")
精彩评论