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.

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

2 posters

Go down

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

Post by Przmus Mon 29 Apr - 2:49

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.
avatar
Przmus
Forumember

Male Posts : 60
Reputation : 2
Language : English

http://easywinclan.forummotion.com/

Back to top Go down

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

Post by Jophy Mon 29 Apr - 4:27

Thanks for sharing the solution thumleft

Since this was marked solved...

Topic Solved & Locked
Jophy
Jophy
ForumGuru

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

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum