I've read that people have asked this question many times and I have found an answer for it, although I had to do it manually for ALL links in my blog. But I'm stumbled with the format that I can't get to work:
the format I use:
<a onclick='location.href="#"' style='cursor: pointer;'target='_blank'>
but I can't get it to work for data:post.href, it won't open at all.
<a onclick='location.href="data:post.href"' style='cursor: pointer;' target='_blank'>
Can anyone please help me with this? Thanks in advance
In general, not having a href link in the is not recommended for SEO reasons. Google's crawler relies on the the href in the links to crawl the site, and link juice passes on using the href in the tag. For your site to rank better in the search results, you will need to href to supply the tree structure for GoogleBot.
To prevent copying I suggest you use a little of jQuery to hide the href tags. It utilises javascript to remove the href tags. On click of the links, it will open a new window with the href location.
Example is provided below:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script>
$(function(){
$("a.hidelink").each(function (index, element){
var href = $(this).attr("href");
$(this).attr("hiddenhref", href);
$(this).removeAttr("href");
});
$("a.hidelink").click(function(){
url = $(this).attr("hiddenhref");
window.open(url, '_blank');
})
});
</script>
<style>
a.hidelink {
cursor: pointer;
text-decoration: underline;
}
</style>
</head>
<body>
<a class="hidelink" href="http://www.google.com">Some Link</a>
</body>
</html>