Script blockquote auto selection - Ash Princess Kawaii
Breaking News
Loading...
07 Oktober 2014

Script blockquote auto selection

Oktober 07, 2014
Auto Seleksi Blockquote

My previous post about the blockquote syntax highlighter. Complicated if we want copied code in the blockquote, especially if the code a lot. To make it easier to copy blocquote code, use the following script blockquote auto selection.


<script type='text/javascript'>
var pres = document.getElementsByTagName(&quot;blockquote&quot;);
for (var i = 0; i &lt; pres.length; i++) {
  pres[i].addEventListener(&quot;dblclick&quot;, function () {
    var selection = getSelection();
    var range = document.createRange();
    range.selectNodeContents(this);
    selection.removeAllRanges();
    selection.addRange(range);
  }, false);
}
</script>

Place that code above  </body>

This script also applies to the pre tag. Replace it 'blockquote' with 'pre'

<script type='text/javascript'>
var pres = document.getElementsByTagName(&quot;pre&quot;);
for (var i = 0; i &lt; pres.length; i++) {
  pres[i].addEventListener(&quot;dblclick&quot;, function () {
    var selection = getSelection();
    var range = document.createRange();
    range.selectNodeContents(this);
    selection.removeAllRanges();
    selection.addRange(range);
  }, false);
}
</script>

Well done.

0 Comments:

Posting Komentar