Friday, August 11, 2006


Every time I link to something, I always include "target='0'" in the code. But it's a drag to do that manually every single time. Is there a way to format things so that when I click on the blogger "link" button, "target='0'" is included in the code?


This Post was written by Emily Stone from Chocolate in Context


Ian said...

I'm not sure why you would wish to add this in the first place?

Julie said...

If you just want to put a link in your blog, like when someone clicks on the word tomatoes in your blog, it is a link to a, then do this:
in blogger, go to edit html and find the word tomato that you want to convert into a link. Use this code:
So the url represents where you want to link to and "tomatoes" represents the word in your blog that is going to become a link.
Hope that helps

Julie said...

Grrr...when I typed out the code, a hotlink was created. I'm going to email you the code I used to create the "tomatoes" hotlink in my previous comment.

Sam said...

Firstly I think you should be sure you want to do this. You should be aware that some web users do not like being forced to openlinks in new windows. Others don't have a problem. This debate has raged on this blog a couple of times before.

Secondly - could you put the code in a template and cut and paste it.

I have many things preset in my own blogger template so I don't have to set them up every time. Target="0" is most certainly not one of them.

Kalyn said...

I agree with Sam, I HATE having links open in new windows. In fact, I'd probably never click on the links in a blog once I realized it was set up that way.

Lynda said...

I am an (almost) complete neophyte when it comes to html and all the other "techie" stuff (though I am just starting to educate myself), but I can weigh in on links that open in new windows debate.

Personally, I prefer when a link opens in a new window. That way, if I open it and look around, I don't have to use the back button (or View) to get back to the original site.

However, since I am never sure if a link is going to open in a new window or not, I have gotten into the habit of (in IE) doing a right-click on links and choosing to open the link in a new window.

This seems like a good compromise - those who don't want a new window can just click normally, while those who prefer a new window can right-click and open the link that way. I'm not sure how other browsers work (or on a Mac), but I would assume there is a way to do something similar.

paul said...

Simple answer: Put <base target="_blank" /> in the head of your template. All links will open in new windows.

Complex answer: Don't do that.

You can read our debate here. Using new windows may come down to a personal preference or user interface no no, but the question really comes down to why do you want to do it?

If it's something you must absolutely have on screen at the same time as the original window (some examples are comparisions, calculation tools, navigation, a form that won't allow you back to the starting point when you're done or my antiquated comment windows) then it's a good idea to use it.

But if you're doing it because you want to make sure your readers don't leave your site, it's not a good idea. Send your readers away to great links, and they will come back on their own.

However, all this debate doesn't answer your question -

There is a complicated way to have all your links in your posts open new windows without pasting in the target everytime using some javascript and CSS. In doing so you can also style those links a little differently so they warn people that they'll do something different.

For the ultra-geeky among us, this technique also gets around the compliance issue (the target tag is not complaint unless using a transitional DTD (if you have to ask, don't worry about it)).

Using Javascript instead of target to open new windows.

With some styling you can add a new window icon like you'll see around sometimes, instead of the text.

The other choice is to use a little form in your menu that will let your visitors toogle the feature on and off.

Emily Stone said...

Wow. Thanks everyone. I never had any idea that this was such a contentious issue. The thing is that I much PREFER when websites are organized to have links open in new windows. For the same reason, I also prefer to print out information that I plan to read and refer to again--I like to have everything in front of me. I guess I'm in the minority.

Well, the simplest solution for the time-being is not to program anything in at all. Thanks to Sam and Paul for the coding advice. And thanks to everyone else as well.