Mar 8, 2011

How to Open Links in New Tab or New Window

This idea has just crossed my mind. I was reading the episode release for One Piece this week. And so when I clicked on the link, a new website opens in the same window. After I've read it, I had to type again the previous website address that I've been reading first.

And so I thought.... can I possibly click-open to a new tab or to a new window when I click a link?

Oh yes I we can!

After scavenging over the net (which I usually do), here is what I found:

1) To open links in a new window, ADD this is the script in your tag :
target="_new"

Hence, the full script would look like this:
<a href="http://www.jackdi.com/" target="_new">Jack Di</a>
For the actual result, click this - Jack Di



2) To open links in a new tab, ADD this is the script in your tag :
target="_blank"

Hence, the full script would look like this:
<a href="http://www.jackdi.com/" target="_blank">Jack Di</a>
For the actual result, click this - Jack Di


These are mighty little script indeed!

However, if you intend to make all links to open in a new window or in a new tab, the above script would be too manual that it becomes too painful to do already. The solution? >>> Put the script in your blog template!

Just insert the script "<base target='_blank' />" anywhere in between your head tags, or anywhere in between <head> <head/> . In my case, I had put it just before
<head/>.

Therefore, it should more or less look like this:

<head>

<base target='_blank' />
<head/>


Pretty easy... right?!
This worked well with me.  I believe this would work well with you too.

:-)

No comments:

Post a Comment

Let's be human and humane. Vulgarities and Spams will not be published. Thanks.

- Jack -