Hello all!
I've waited for someone to post about this problem, but as I see nobody noticed this, or maybe that's not a problem at all. For me it is not a big problem too, but it's quite annoying. So, it's about "Select content" button. When I push that button, then copy selected text and paste it anywhere, I always get four extra spaces (not line-breaks, just spaces) at the beginning of the code. It happens on my forum, and on this forum too. It never happened earlier, while I was using old JavaScript code for that button. But one day it stopped working, and I got new JS. Here it is:
My question is, does this have any solution, or it is normal for select content function to act like that? If there is any way to fix it, I'll be very grateful for your ansvers. Any help appreciated!
I've waited for someone to post about this problem, but as I see nobody noticed this, or maybe that's not a problem at all. For me it is not a big problem too, but it's quite annoying. So, it's about "Select content" button. When I push that button, then copy selected text and paste it anywhere, I always get four extra spaces (not line-breaks, just spaces) at the beginning of the code. It happens on my forum, and on this forum too. It never happened earlier, while I was using old JavaScript code for that button. But one day it stopped working, and I got new JS. Here it is:
- Code:
function selectCode(a){a=$(a).closest("dl").find(".cont_code,code")[0];if(window.getSelection){var c=window.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(a,0,a,a.innerText.length-1);else{window.opera&&a.innerHTML.substring(a.innerHTML.length-4)=="<BR>"&&(a.innerHTML+=" ");var b=document.createRange();b.selectNodeContents(a);c.removeAllRanges();c.addRange(b)}}else document.getSelection?(c=document.getSelection(),b=document.createRange(),b.selectNodeContents(a),
  c.removeAllRanges(),c.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.select())}
     Â
  $(function(){
  $("dl.codebox:not(.spoiler,.hidecode)  > dd.code, dl.codebox:not(.spoiler,.hidecode)  > dd > code").closest("dl").find('dt').append('<span onClick="selectCode(this)" class="selectCode">Select content</span>');
  });
My question is, does this have any solution, or it is normal for select content function to act like that? If there is any way to fix it, I'll be very grateful for your ansvers. Any help appreciated!
Last edited by ifelthope1126 on May 23rd 2014, 11:41 pm; edited 1 time in total