Hocam ilgilendiğin için çok sağolasın. Bu şekilde br taglarını iptal etme işi düzeldi. Ancak link çıkmadı. Yabancı forumlarda bi kod buldum oldu. Bu kodda kopyalanan içeriği <div> kodları arasına alıyor. Bunu iptal etmiş olsam tam isteğim olmuş olacak. Kodu wordpress te kullanıyorum. Lazım olanlar için ekliyorum.
<?php $cats = get_the_category();
foreach( $cats as $cat ) { ?>
<script type='text/javascript'>
function addLink() {
var selection = window.getSelection();
var htmlDiv = document.createElement("div");
for (var i = 0; i < selection.rangeCount; ++i) {
htmlDiv.appendChild(selection.getRangeAt(i).cloneContents());
}
var selectionHTML = htmlDiv.innerHTML;
var pagelink = "Source: <?php the_title(); ?> <a href='<?php echo get_permalink(get_the_ID()); ?>'><?php the_title(); ?></a> | <a href='<?php echo get_category_link($cat->term_id); ?>'><?php echo $cat->name; ?>";
var copytext = selectionHTML + pagelink;
var newdiv = document.createElement('div');
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () { document.body.removeChild(newdiv); }, 0);
}
document.oncopy = addLink;
</script>
<?php break;
} ?>
Önce Bu Fonksiyonu ekle :
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
}
}
return html;
}Sonra İlk verdiğin koddaki
var selection;
selection = window.getSelection();
kısmındaki Yeri değiştir :
selection = getSelectionHtml();
Problem düzelecektir.