Nathan323 Posted May 11, 2007 Share Posted May 11, 2007 I have recently found & have been using a reg/javascript combo that allows you to search a word on Wikipedia (or any search) by selecting text on web page, then choosing option from context menu of selection. This is the code that the reg hack looks at: <script language="Javascript" defer> var parentwin = external.menuArguments; var doc = parentwin.document; var sel = doc.selection; var rng = sel.createRange(); var strhtml = new String(rng.htmlText); var str = strhtml.replace(/<[^>]*>/g," "); str = str.replace(/\s+/g, " "); str = str.replace(/^\s*/,""); str = str.replace(/\s*$/,""); var bnewwindow = external.menuArguments.event.shiftKey; var url = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search&search=" + escape(str); try { url = gg.Search(String(str)); bnewwindow = gg.OpenNewWindow(); } catch (ex) { } if(bnewwindow) parentwin.open(url); else parentwin.navigate(url); </script> I want the results to open in a new window, at the moment results open in current window. So ideally I could have two options, one for new window & one for same window. Thanks for all help. Link to comment Share on other sites More sharing options...
dis Posted May 13, 2007 Share Posted May 13, 2007 u can change this: parentwin.navigate(url) to window.open(url); btw you dont have to change this script because it already has the option for opening new window! ( var bnewwindow = external.menuArguments.event.shiftKey; ) so, it means if you hit the shift key while you select a text and click your menuitems, it will open in new window. :) Link to comment Share on other sites More sharing options...
Nathan323 Posted May 13, 2007 Author Share Posted May 13, 2007 Great, thx mate. Link to comment Share on other sites More sharing options...
Recommended Posts