3 replies [Last post]
gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 4 years 39 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Suppose i have alot a link like the below , it makes sense to add the attribute target="_blank" , but what if i have 10 o
f these kind of links , should i than add that attribute to the 10 links using JS ?? is that a better idea , i think that will help keep my HTML doc clean Laughing out loud

good idea ? bad idea ?

<a href="abc.com" target="_blank"><i class="icon fa fa-google-plus"></i></a>

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 15 weeks 6 days ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

IMO

Using the target attribute for forcing a new window or tab is a Bad Idea. It only pisses off your visitor and clutters his browser. The target attribute was deprecated in 1999 except for use in frames. Unfortunately, html5 is bringing it back due to the silly concept of paving the cowpath; anything that people use or browsers support for legacy reasons is being made valid. this is the reason html got so messy in the first place.

If you're going to do that silliness anyway, you could always simply paste the attribute/value into the various 'a' elements willy-nilly.

You may have got the idea that I am not a fan of developers' sending me to a new window or tab. If I, or any user wants the link to open in a new tab, we can do it ourselves. We don't need to be forced.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 23 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

What he says! If you really

What he says!

If you really have to do this and lord knows everyone wants to nowadays - so much for a decade of establishing Standards and best practises - do so via JS, jQuery makes this easy set anchors with a class 'new-win' and use that to set the elements with the target attribute

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 4 years 39 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Thanks Gary and Hugo !

Yes i taught so JS would be a good option . Thanks @gary and @Hugo ! (: