I'm afraid your question is not very clear. You use target="_blank" on links, but it is very outdated and not good to use any more.

But is is used like so:

<a href="#" target="_blank">Contact</a>

You have a strict doctype, and tarter="_blank" is not allowed with that doctype, so the page won't validate.

SpikeZ
—
2012-03-01T11:55:06Z —
#2

[ot]

ralph_m said:

You have a strict doctype, and tarter="_blank" is not allowed with that doctype, so the page won't validate.

mmmm tarter sauce....[/ot]

ralphm
—
2012-03-01T11:59:54Z —
#3

By the way, you have a strict doctype, so target="_blank" also is not allowed with that doctype, so the page also won't validate if you use that. :shifty:

TechnoBear
—
2012-03-01T17:23:36Z —
#4

[ot]

spikeZ said:

mmmm tarter sauce....

More tart than what? Or were you thinking of tartar sauce? [/ot]

SpikeZ
—
2012-03-01T20:22:26Z —
#5

Off Topic:

mmm tartier....... drool

TechnoBear
—
2012-03-02T17:52:44Z —
#6

chol7024 said:

Ex: you are visiting it and now you click on post title sure it will give you another page. Refer to my question is, I don't want you to leave my home page by click on this title. Meanwhile home page still appear and new page is also appearing after that.

You mean you want the new page to appear in a new window? ralph.m gave you an example of how to do that, but he also explained that it is no longer considered good practice. It means that people can't get back to where they were using the back button, and it can be particularly difficult and annoying for those using screen readers and other assistive technologies.

Why do you want people to keep your home page open when they're visiting another page? After all, most people can only read one page at a time.

TehYoyo
—
2012-03-03T01:33:42Z —
#7

TechnoBear said:

You mean you want the new page to appear in a new window? ralph.m gave you an example of how to do that, but he also explained that it is no longer considered good practice. It means that people can't get back to where they were using the back button, and it can be particularly difficult and annoying for those using screen readers and other assistive technologies.

Why do you want people to keep your home page open when they're visiting another page? After all, most people can only read one page at a time.

Although it's now allowed in HTML5.

How dost one open the link in a new window now? Presumably with they power of CSS?

~TehYoyo

ralphm
—
2012-03-03T02:09:19Z —
#8

TehYoyo said:

How dost one open the link in a new window now? Presumably with they power of CSS?

Usually with JavaScipt these days. E.g. if you are already using jQuery onthe site, you can add something like

Yeah, I don't really understand it either. But in this case, it tells the browser to add target="_blank" to any link that includes "http" in its URL. So, for example, you could use this on a site where you wanted any link that includes "http" to open in a new window (such as an external link) but not to do so for internal site links (which might, for example, be root relative links, and thus not contain "http").

If you just wanted all links to open in a new window, you could just use

$(document).ready(function(){
$("a").attr('target','_blank');
});

All the same, as has already been discussed, this kind of behavior is not recommended now anyway, as it is confusing to users and kind of ruins the functionality of the web (the back button etc.).

If you are going to use tartet="_blank", it's a good idea to use an outdated transitional doctype, to help remind you that the site is using outdated code. Except that ...

TehYoyo said:

... it's now allowed in HTML5.

Indeed, that's the case—which is consistent with the HTML5 motto of "paving the cowpats" [typo intended :)].

can you use jQuery to only open some links in new windows? For instance, I imagine internal page links and links to other parts of the site would want to be same-window links.

You can create any combination you like, but the example I first posted was just to open external links in a new window, with the idea that you don't want people to leave your site to go to a new one. (I had a client once that insisted on this, despit my objections.)

Also, why should we use jQuery to add attributes rather than just doing it ourself? Ease of use?

Either just to get around the validator (if you have a strict doctype) or as an easy way to reverse engineer a site so that you don't have to go around adding the attributes manually. But other than that, it is indeed pointless to use JS to do this.

ralphm
—
2012-03-03T04:38:45Z —
#13

chol7024 said:

Sorry my HTML knowledge is poor and now using HTML in Blogger. Can you share...

Just to clarify ... I did a site once that had many internal links (to other pages within the same site), such as

<a href="/contact/">contact us</a>

and lots of external links (to other sites) like

<a href="http://someothersite.com">bye bye</a>

Suddenly, the client demanded that all external links open in a new window (so that people wouldn't leave his site when they clicked an external link).

Instead of going through the whole site and adding hundreds of target="_blank" attributes to all those external links, I just added this simple code to the <head> of each page (which I did just once, because most of the <head> content was fed to each page via a single include file):

That's a much simpler solution, even though it means the user will have do download the entire jQuery library! (In the case of the site, that was already being used for other purposes anyway, so I've just added that first line above to show how you could do this if you weren't already using jQuery on the site.)