Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 29-10-2010, 07:54 PM   #1 (permalink)
Banned
 
slugger's Avatar
 
Join Date: May 2004
Location: Baudland
Posts: 2,433
Default javascript to open page in new tab


Hi,
I recently dragged this bookmarklet into my browser [forgot the site - will post it if it remember].

Code:
javascript:d=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);d=d.replace(/\r\n|\r|\n/g,"%20,");if(!d)d=prompt("Enter%20the%20words:",%20"");if(d!=null)location="http://www.google.com/search?q=define:"+escape(d).replace(/%20/g,"+");void(0);
What it does is, once you highlight a word in the browser and then click on the bookmarklet, it will search Google using the define: search operator - very nifty for imporving vocabulary
As seen from the code, the search page opens up replacing the original page where that word had appeared - very inconvininet as you will have to go back again to read it

As I have no knowledge of javascript, my attempts at trying to modify the code to get the search page open up in a new tab, leaving the original page untouched has failed till now

Can some kind soul please do it for me

Thanks
slugger is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 30-10-2010, 01:53 AM   #2 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: javascript to open page in new tab

Code:
javascript:d=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);d=d.replace(/\r\n|\r|\n/g,"%20,");if(!d)d=prompt("Enter%20the%20words:",%20"");if(d!=null)window.open("http://www.google.com/search?q=define:"+escape(d).replace(/%20/g,"+"));void(0);
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline   Reply With Quote
Old 30-10-2010, 08:11 AM   #3 (permalink)
Banned
 
slugger's Avatar
 
Join Date: May 2004
Location: Baudland
Posts: 2,433
Default Re: javascript to open page in new tab

^^
Thanks a lot
slugger is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2