function _dictGetSel() if (window.getSelection) return window.getSelection(); else if (document.getSelection) return document.getSelection(); else if (document.selection) return document.selection.createRange().text; else return ''; } //main entry var word; if (confirm("Select OK to add selected contents into Will Power, Cancel to abort")) { word = _dictGetSel(); word=""+word; } else { word = "Operation Canceled"; } alert(word);