The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Read More link to Copied Text... the line breaks and formatting are ignored

View previous topic View next topic Go down

Read More link to Copied Text... the line breaks and formatting are ignored

Post by Ahmed.K on June 14th 2014, 9:29 am


I am using this code to add a read more link to my copied text but the line breaks and formatting are ignored:

Code:
$(document).ready(function () {
  document.body.oncopy = function () {
  var body_element = document.getElementsByTagName('body')[0];
  var selection;
  selection = window.getSelection();
  var pagelink = "<br />Read more at: <a href='" + document.location.href + "'>" + document.location.href + "</a><br />";
  var copytext = selection + pagelink;
  var newdiv = document.createElement('div');
  body_element.appendChild(newdiv);
  newdiv.innerHTML = copytext;
  selection.selectAllChildren(newdiv);
  window.setTimeout(function () {
  body_element.removeChild(newdiv);
  }, 0);
  };
});

How to preserve them?

There is a good code: http://jsfiddle.net/acdcjunior/XKjNz/9/
But doesn't work here.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

View previous topic View next topic Back to top


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