by coe15 on Fri May 16, 2008 6:28 am
//this the code for selecting the highlighted text... Please help..
/ Grab.js
(function(){
//javascript:
var d,w,s,x,h="";
if (window.getSelection) {
s = window.getSelection();
if (s.rangeCount && !s.getRangeAt(0).collapsed){
x = document.createElement("div");
x.appendChild(s.getRangeAt(0).cloneContents());
h=x.innerHTML;
}
} else {
h = document.selection.createRange().htmlText;
}
if(h){
//d=window.open().document;
//d.close();
//alert(h);
// create form
myform = document.createElement("Form");
myform.action ="http://localhost/work/try.php";
myform.method = "post";
// create input
myinput = document.createElement('input');
myinput.type='hidden';
myinput.name='h';
myinput.value = h;
myform.appendChild( myinput);
myinput2 = document.createElement('input');
myinput2.type='hidden';
myinput2.name='src';
myinput2.value = location.href;
myform.appendChild( myinput2);
mysubmit = document.createElement('input');
mysubmit.type='submit';
myform.appendChild( mysubmit);
document.body.appendChild(myform);
//self submit
myform.submit();
}
})();