"Выделить код"
HTML-низ
<script type="text/javascript"> function select_text(elem) { if(window.getSelection) { var s=window.getSelection(); if(s.setBaseAndExtent){ s.setBaseAndExtent(elem,0,elem,elem.innerText.length-1); } else { var r=document.createRange(); r.selectNodeContents(elem); s.removeAllRanges(); s.addRange(r); } } else if(document.getSelection){ var s=document.getSelection(); var r=document.createRange(); r.selectNodeContents(elem); s.removeAllRanges(); s.addRange(r); } else if(document.selection){ var r=document.body.createTextRange(); r.moveToElementText(elem); r.select(); } } </script> <script type="text/javascript"> var div = document.getElementById('pun-main').getElementsByTagName('div'); for(x in div){ if(div[x].className=='code-box'){ div[x].getElementsByTagName('strong')[0].innerHTML = '<a href="#" onclick="select_text(this.parentNode.parentNode.childNodes[1].getElementsByTagName(\'pre\')[0]); return false;">Выделить код</a>'; } } </script>