[JavaScript]获取网页中选中部分的源代码
转载自from: http://topic.csdn.net/u/20090109/21/70c206df-bfc9-4f11-b3d2-4b99b2471e2b.html
function Gethtmlcode() {
var rng=null,html="";
if (window.document.selection && window.document.selection.createRange){
rng=window.document.selection.createRange();
html=rng.htmlText;
}else if (window.getSelection){
rng=window.getSelection();
if (rng.rangeCount > 0 && window.XMLSerializer){
rng=rng.getRangeAt(0);
html=new XMLSerializer().serializeToString(rng.cloneContents());
}
}
浙公网安备 33010602011771号