How to create a CrossBrowser Bookmarklet?
January 24, 2007 10:08 PM   Subscribe

I have written a bookmarklet that works in Firefox but not in IE6. How can I change it to be supported cross browser or even as a separate bookmarklet to get the same results.

javascript:Qr=document.getSelection();if(Qr)location.href='http://jobsearchlog.com/ba.cfm?ad='+escape(Qr)+'&description='+encodeURIComponent(document.title)+'&tags=%s'+'&ad4user=mickbw&url2job='+window.location.href;

Much of the JS was taken from the send to Delicious bookmarklet but I've never seen it work in IE anyway.

The purpose of the 'let is to send whatever text in a page has been selected, the URL and page title and submit the values into a database for use in my web application. In Firefox they would also be able to specify tags to be included in the insert.

Any suggestions on making this work in IE?
posted by mickbw to Computers & Internet (5 answers total)
 
Best answer: One problem is the document.getSelection method. More here.
posted by Rhomboid at 11:07 PM on January 24, 2007


Best answer: If you didn't get it from Rhomboid's link, you can fix it like:

javascript:Qr=(document.getSelection)?document.getSelection():document.selection.createRange().text;if(Qr) location.href='http://jobsearchlog.com/ba.cfm?ad='+escape(Qr)+'&description='+encodeURIComponent(document.title)+'&tags=%s'+'&ad4user=mickbw&url2job='+window.location.href;
posted by moift at 10:54 AM on January 25, 2007


Why not just create two, one for IE and the other for Mozilla browsers? You can detect which browser they're on and offer them the appropriate one.
posted by AmbroseChapel at 1:30 PM on January 25, 2007


Response by poster: Sorry for the delay in marking this as the best answer.

I had moved on to another more pressing problem and finally got back to this issue.

Thanks for all the help to everyone.

Michael
posted by mickbw at 8:16 PM on March 3, 2007


Response by poster: I'm sorry for the delay in responding to these answers. Thanks for all the help

Michael
posted by mickbw at 8:17 PM on March 3, 2007


« Older Searching for Obscure World Currency   |   Should we move to Honolulu? Newer »
This thread is closed to new comments.