Javascript bookmark dialogs stopped working
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?
Modified
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)
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();
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.