Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Javascript bookmark dialogs stopped working

  • 2 replies
  • 7 have this problem
  • 1 view
  • Last reply by trocon

more options

I have some bookmarks on my Bookmarks Toolbar whose address is a Javascript snippet:

javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Enter subject to lookup in Wikipedia:',''))}if(Qr)location.href='http://en.wikipedia.org/wiki/Special:Search/'+escape(Qr)+'%20'

This will open a dialog box asking "Enter subject to lookup in Wikipedia", and takes that word or phrase and passes it on to Wikipedia's search page. With some editing, this code can also work for other sites, like dictionary.com.

So, when I upgraded to Firefox 8, these JS bookmarks turned into dotted squares for icons, and they no longer open a dialog box. Instead, only the site itself displays.

I've searched for a solution, but all I found were references to "keyword bookmarks". But AFAIK this is a different concept, because they're meant to be typed in the address bar, e.g. "w searchterm", and I don't know how it could be made into an item on the bookmark toolbar.

Any ideas for a workaround?

I have some bookmarks on my Bookmarks Toolbar whose address is a Javascript snippet:<br /> <br /> <pre><nowiki>javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Enter subject to lookup in Wikipedia:',''))}if(Qr)location.href='http://en.wikipedia.org/wiki/Special:Search/'+escape(Qr)+'%20'</nowiki></pre> This will open a dialog box asking "Enter subject to lookup in Wikipedia", and takes that word or phrase and passes it on to Wikipedia's search page. With some editing, this code can also work for other sites, like dictionary.com. So, when I upgraded to Firefox 8, these JS bookmarks turned into dotted squares for icons, and they no longer open a dialog box. Instead, only the site itself displays. I've searched for a solution, but all I found were references to "keyword bookmarks". But AFAIK this is a different concept, because they're meant to be typed in the address bar, e.g. "w searchterm", and I don't know how it could be made into an item on the bookmark toolbar. Any ideas for a workaround?

Modified by cor-el

Chosen solution

In Firefox 8 getSelection() returns an object and no longer a string.
So you need to force it to a string by either adding +"" or use the toString() method.

Qr=document.getSelection()+"";
Qr=document.getSelection().toString();

Read this answer in context 👍 2

All Replies (2)

more options

Chosen Solution

In Firefox 8 getSelection() returns an object and no longer a string.
So you need to force it to a string by either adding +"" or use the toString() method.

Qr=document.getSelection()+"";
Qr=document.getSelection().toString();

more options

Excellent, thanks for such a prompt and concise solution.

I could not get the second method (toString) to work, for some reason... it seems to pass the entire function on to the website. However, the first one works perfectly, so I just changed them all that way.