Saturday, February 05, 2011

How to make each link open in a new window

This was a potential WFMW post that has been on my mind for some time.  Nothing exciting, just useful, and delivered on a Saturday.  no extra charge.  :)

Why is it important to make each link open in a new window?  Well, without your reader having to right-click which doesn't always work (like if they have it disabled so you don't steal images or something), but you don't want them to leave your blog when following a link, this comes in handy.

I like to right-click and open a new window if I'm not done reading something but don't want to forget that I want to read that new thing too.

On my blog, I have been manually entering in target="_blank" for each link in every post under the Edit HTML tab to make my links open a new window for you.  But sometimes I forget and then go back and add it in.  Attempting to explain this to you, not in person, just threw me for a spin.

But someone much html smarter and gads more creative than me figured it out in such a way to make it simple.  And you don't have to do it for every link like I had been doing.  Enter the html code ONCE in the right place, and you're all set!

Okay, maybe it is a little exciting.

Here's her link.  I did it on my blog so you needn't worry about accidentally leaving me.  I get worried too about you leaving me.  Now we'll be together.  always.  And I didn't even have to take any online classes to find this out!

10 comments:

Unknown said...

Someday I could show you some jacascript that would do it only for links that aren't from your blog so if they are navigating to other link in your blog they don't get 20 windows/tabs :)

Nikki said...

Zoramite- Ooh! You should do a tutorial on your blog. I'm certain there are many more people than just me that would be interested.

Which reminds me, I've been meaning to ask you about the posts that show time-lapse. Do you need a fancy-schmancy camera for that? That also reminds me, I need to call you. :P

Unknown said...

Here is the code to do the external links:

https://gist.github.com/812525

I'll probably write up a blog post about it too, but that is the actual code. If you want to use it and need any help just let me know. :)

It was a nice little morning excercise...

Unknown said...

And here is the blog post:

http://forthedeveloper.com/2011/external-links-in-a-new-window/

The Single Nester said...

Great post. I hate when I click on a post or photo and I am taken away from the original blog page which I wanted to continue reading on. I better make sure this is the case with my blog.

Nikki said...

Randy-

Thanks for those links. I'm going to have to wait until after bedtime to do this so I can really concentrate. Right now a certain five year old is complaining to me about not passing "Blustery Day" on The World of Goo.

Teachinfourth said...

So, you are needy like that...

I used to add in the 'open in new page' html but then I got lazy...hopefully my blog is good enough that people will want to come back after they leave.

Nikki said...

Teachinfourth- You are so hilarious!

Lisa said...

Oh my goodness! This is so great! I am so excited!!! Thanks Nikki. :0)

P.S. ~ What an adorable family you have! You sure do have your hands full!

Elaine Shandra said...

How exciting! I almost always do the right-click thing. My blog is now equipped with the new code, thanks!