Making links open in a new tab
Sometimes, you need to refer to outside material in your blog: your ability to quote it is controlled by copyright laws, so you may need to link to an outside source, rather than quoting it in full.Blogger's Post Editor has a tool for changing some text into a link - and it's been much easier to use since they added a check-box turns the "open on a new tab / window" option on/of. If you tick this option, then the post-editor automatically adds target="_blank" (the HTML code for this) to your link.
For example
< a href="www.blogger-hints-and-tips.blogspot.com"> Blogger-HAT's Home Page </a>becomes
< a href="www.blogger-hints-and-tips.blogspot.com" target="_blank"> Blogger-HAT's Home Page </a>
Doing it automatically
Occasionally there are requests in the Blogger Help Forum like"How can I make all the links in my blog open in a new window"These often cone from people new to Blogger who, understandably, want to keep the traffic on their site.
There are ways to do this, provided you're willing to accept the disadvantages of editing your template - this explanation shows how to do it. Although this approach works, the advice in the help-forum usually includes a warning to think very carefully about whether you really want your visitors to see a new page whenever they look at your own "about" page or one of your older posts.
Another option is to set the blog up so that only external links (ones to pages outside your own URL) open in a new window. To do this:
- Edit your template in the usual way.
- Find the </head> statement
- Put the following code immediately before the </head> statement - except don't add the purple line if you already have it somewhere else in your template.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script> <script type='text/javascript'>
$(document).ready(function() {
$("a[href^='http://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}
}
);
$("a[href^='https://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}
}
);
});
</script>
It's not a good idea for AdSense publishers
The approaches described above work. But there is one issue that's often not mentioned: the relationship between this command, and the terms and conditions of other tools that you may be using on your blog.I'm no lawyer, but it seems clear to me that setting your links to automatically open in new pages would be a clear violation of this.
So based on this, I would recommend that
If you use AdSense,
Then don't install auto-new-page code into your template, and check that any 3rd party templates that you use don't have this feature either.
If this advice worries you, you may like to use an alternative advertising programme: it seems that Chitika, at least, does let you customise your ads in this way.
It's fine to open individual links on a new page - just don't do it for all of them.
Disclaimer: this advice is based on my interpretation of the Terms and Conditions. Caveat emptor. Always read the terms and conditions yourself, every publisher is responsible for making sure that their site complies.
Related Articles
Setting up AdSense on your blogAlternative advertising programmes
Copyright, blogs and bloggers
Advantages and disadvantages of editing your template
Extra customization of Chitika ads
Other tools you may like to use on your blog
Thanks, this helped alot, and was easy to understand!
ReplyDeleteYes Interesting I had not thought of that at all.
ReplyDeleteThe LINK at the end of "Another option is to set the blog up so that only external links (ones to pages outside your own URL) open in a new window - one way to do that is described here " goes astray
ReplyDeleteThanks for letting me know, it seems that the external site I was pointing at is now longer operational. I've updated the post with new information.
Delete