It's been tested on IE only. Modification will probably be required for other browsers.
<script type = "text/javascript">
function doClick() {
openNewLookupWin('http://www.google.com/search?q=');
}
function doDblclick() {
openNewLookupWin('http://www.onelook.com/?w=');
}
function getSelection() {
if (navigator.appName == "Netscape") {
t = document.getSelection();
return t;
} else {
t = document.selection.createRange();
if (document.selection.type == 'Text' &&
t.text != '') {
return t.text;
}
return '';
}
}
function openNewLookupWin(call) {
var text = getSelection();
if (text == '') return;
window.open(call + '"' + escape(text) + '"');
}
</script>
Be sure to include the following in the <body> tag.
<body ondblclick = "doDblclick()" onclick = "doClick()">
1 comment:
That is one cool javascript!!
Post a Comment