Alan Lauer
Alan Lauer

Reputation: 43

Bookmarklet on blank page

I've written a simple bookmarklet that opens multiple web pages with a single click:

javascript:(function(){window.open("http://www.w3schools.com");window.open("http://www.google.com");window.open("http://www.yahoo.com");})();

I wan't to be able to open the browser and click this immediately, but the bookmarklet won't work unless a page is already loaded in the window. I prefer to have my browser home page set to "Blank" for speed. Is there a way to make this bookmarklet execute without a page already loaded?

Also, I'd like the bookmarklet to replace whatever page is loaded in the window, if something is indeed loaded. At present, it opens 3 new tabs. I've tried the "_self" and "_parent" values for the "name" attribute on the first window.open, but it doesn't seem to work. I may not be formatting it correctly.

Any help is appreciated! Thanks!

Upvotes: 4

Views: 3220

Answers (2)

Piyush Soni
Piyush Soni

Reputation: 1406

I was having the same problem, and learned from the internet that if you go to your about:config, search for browser.newtab.url and change it to about:blank instead of the default about:newtab your javascript bookmarklets should work (just tried, and it's working!). This should be cleaner than doing a data:text/html message (in any case even if you set the homepage it doesn't work for every new tab, only once for a new window)

Upvotes: 2

Chocimier
Chocimier

Reputation: 76

It isn't possible to open bookmarklet in no page.

Instead, you can try to set your homepage to something like data:text/html,Welcome! (yes, it IS a working URL).

To open a page in the same tab, type:

location.href='http://www.w3schools.com'

Upvotes: 6

Related Questions