I have been working on modifying a javascript that will allow users of my website to copy/paste without bringing along all those HTML formats. I am not fluent with Javascript so for me it is a lot of hit and miss, usually with mostly misses. The script was originally designed to add a copywrite notice and link to any copy and pasted text. One problem I have been having I was able to do a sort of patch for instead of an actual fix. I changed the background color to white because the webpage body is gray.
What I want to do is instead of CHANGE colors, or fonts, or whatever, I want to just DROP all those unwanted formats sort of like right clicking and paste as unformatted text. I would sure welcome any suggestions or help anyone could offer.
So far this is what I have:
<script type="text/javascript">
function Format() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
var copytext = selection;
var newdiv = document.createElement('div');
newdiv.style.background = "white";
body_element.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function() {
body_element.removeChild(newdiv);
},0);
}
document.oncopy = Format;
</script>