The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Problem with "Add a Copyright Notice to Copied Text" script

    avatar
    Przmus
    Forumember


    Male Posts : 60
    Reputation : 2
    Language : English

    Solved Problem with "Add a Copyright Notice to Copied Text" script

    Post by Przmus April 29th 2013, 4:49 am

    I found a script:
    Source: http://bavotasan.com/2010/add-a-copyright-notice-to-copied-text/
    Code:
    <script type="text/javascript">
    function addLink() {
       var body_element = document.getElementsByTagName('body')[0];
       var selection;
       selection = window.getSelection();
       var pagelink = "<br /><br /> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright © c.bavota"; // change this if you want
       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 = addLink;
    </script>

    I added it to: "Javascript codes management" and it doesn't work.
    When I added it to: "Announcements" - it works fine.
    Why? I don't want this script in announcements, because it creates an additional break on top of the page.
    I also tried to add this script to "Templates" (overall_header, simple_header, overall_footer_begin, overall_footer_end) and it didn't work.

    I use phpBB2 (subsilver) theme version of the forum.

    Why this script works in "Announcements", but doesn't work in "Javascript codes management"?


    SOLVED:
    It still doesn't work in "Javascript codes management", but when I removed:
    Code:
    // change this if you want
    it works in overall_header.
    Jophy
    Jophy
    ForumGuru


    Male Posts : 17922
    Reputation : 836
    Language : English
    Location : Somewhere

    Solved Re: Problem with "Add a Copyright Notice to Copied Text" script

    Post by Jophy April 29th 2013, 6:27 am

    Thanks for sharing the solution thumleft

    Since this was marked solved...

    Topic Solved & Locked

      Current date/time is November 11th 2024, 7:32 pm