Tự động để lại link bài viết khi copy trong Xenforo

  • Thread starter Thread starter PVS
  • Ngày gửi Ngày gửi
[VNXF] Theme Digital – Sự lựa chọn hoàn hảo cho diễn đàn công nghệ hiện đại

PVS

Super Moderator
Thành viên BQT
Tự động để lại link bài viết khi copy trong Xenforo demo như sau

untitled.PNG

Các bạn làm như sau:
Mở Template PAGE_CONTAINER chèn đoạn này vào trên thẻ </head>
Mã:
<script type="text/javascript">
function protectContent() {
                var body_element = document.getElementsByTagName('body')[0];
                var selection;
                selection = window.getSelection();
                var pagelink = "<br /><br /> Nguồn tại: <a href='"+document.location.href+"'>"+document.location.href+"</a><br /> Trang chủ: <a href='http://vnxf.vn'>http://vnxf.vn</a>";
                var copytext = selection + pagelink;
                var newdiv = document.createElement('div');
                newdiv.style.position='absolute';
                newdiv.style.left='-99999px';
                body_element.appendChild(newdiv);
                newdiv.innerHTML = copytext;
                selection.selectAllChildren(newdiv);
                window.setTimeout(function() {
                    body_element.removeChild(newdiv);
                },0);
            }
document.oncopy = protectContent;
/*]]>*/
</script>

Chúc bạn thành công


Nguồn: kenh88.biz​
 
Back
Top