I'm using following JS code to add extra information[LINK] to clipboard while copying the text from website:
$(document).on('copy', function(e)
{
var sel = window.getSelection();
if(typeof short_url =='undefined'){
if(window.location.hash=="")
{
var url=document.location.href.split('#')[0];
}
else
{
var url=document.location.href;
}
}else{
var url=short_url;
}
var copyFooter = "<br /><br /><a target='_blank' href='" + url + "'>" + url + "</a>";
var copyHolder = $('<div>', {html: sel+copyFooter, style: {position: 'absolute', left: '-99999px'}});
$('body').append(copyHolder);
sel.selectAllChildren( copyHolder[0] );
window.setTimeout(function() {
copyHolder.remove();
},0);
});
Here the problem is, the text is not copied in exact format(return carriage and line breaks). Instead all text are copied as single line text.
How can the issue be resolved?
Possibly duplicated from Problem detecting Newlines in JavaScript Range Object ?
Try using sel.toString() if the text is contained in an editable div, or getRangeAt(0) and toString() combined if it's contained in a non editable div.
I have found a few examples out there but having a hard time getting any to work, if anyone had a clearer or some insight would be much appreciated. var wrap = function() { var self = d3.select(this),...
I have found a few examples out there but having a hard time getting any to work, if anyone had a clearer or some insight would be much appreciated. var wrap = function() { var self = d3.select(this),...
How do I keep only one definition visible at the same time in this example: In other words: Clicking on i button should toggle class on itself and the definition below the term, and remove ...
How do I keep only one definition visible at the same time in this example: In other words: Clicking on i button should toggle class on itself and the definition below the term, and remove ...
Anchor tag not downloading file in IE, instead it gives the option to search for app in app store to open file. For chrome and FF this code is working fine. I don't know this is happening in windows 7 ...
Anchor tag not downloading file in IE, instead it gives the option to search for app in app store to open file. For chrome and FF this code is working fine. I don't know this is happening in windows 7 ...
it is concerning my final year project on web development. i want to change the contents of my page without reloading the page- i know this can be achieve using css /ajax or jquery but that would be ...
it is concerning my final year project on web development. i want to change the contents of my page without reloading the page- i know this can be achieve using css /ajax or jquery but that would be ...