Tech Ravings

An Opinion is a Terrible Thing To Waste
Subscribe

Archive for the ‘HTML’

What’s your target. I hope it’s not new!

July 17, 2007 By: ScottK Category: HTML No Comments →

I have been seeing several websites that like to open new pages with the target=”new” anchor tag. Let me discuss why this is a bad thing, in fact you are telling the browser to fail safe if you do not have a frame named new. With no frames of said name you could be causing your visitors who use *cough* I.E. problems. In I.E. by calling target=”new” does open a new tab/window but any subsequent click in the previous page changes the window in the called window. It’s a real pain.

Let’s examine the use of the target attribute on the anchor element. For those who may not understand what I am referring to that’s cool. The <a is actually an element of the Document Object Model (aka Document Node Mode). An attribute is anything that describes said element: ie href=, target=, style=, onclick=, etc. Although in HTML the common written text is <a href=”http://www.techraving.com” mce_href=”http://www.techraving.com”>.

In order to produce targets within the same web page to find certain sections we need to have named anchors. <a name=”new”></a>. So when an anchor is written to find the href=”#new” mce_href=”#new”, <a href=”#new” mce_href=”#new”>New</a> then the named page is scrolled down to at the appropriate position. What happens if I change the referring link to: <a href=”#” mce_href=”#” target=”new”>New</a>? Well a new window pops up without scrolling the page to the “new” named anchor. Why is that? Frames!

Frames were very popular once and out of this frames navigation was needed. To achieve this the target= written in alphanumeric means find a frame with name= equal target=. <a target=”new”… means find frame name=”new”. You could literally do the same thing by saying <a target=”Fred” equals find frame name=”Fred”. Once new or Fred were found then the href page was displayed in that frame.

What’s a browser to do when the named frame was not found? FAIL SAFE! How the browser achieves this is truly dependent on the browser however. FireFox opens a new window every time. Internet Explorer will replace the window of the last opened by the previous calling page. Meaning if you are doing this and I have two pages of interest too me I can only see one at a time as clicking one link will open a new window but the second link will replace the first.

Whether you are techy or not reviewing the official w3c explanation: http://www.w3.org/TR/html4/types.html#h-6.16 would really help to understand. Certainly you can have differing opinions with me or the w3c and continue to use the target=”new” attribute. However and silently do this, create within your page this piece of code:

<iframe name=”new” width=”300″ height=”300″></iframe>

If your anchor does not open within this iframe then by all means you can contact me or the browser manufacturer you are using. I suggest with me first. However before you do try your anchor target=”_blank” and see what happens.

Unless your website is dealing with navigation between frames or iframes any target that does not have a target=”_ is only causing your visitors trouble. You as a webmaster/owner can not dictate what browsers your visitors are using or how the browsers themselves act so you must try to stand on what is publicized on the standards that everyone hope to achieve across browsers.


ss_blog_claim=ef6135f29164404afb5ea2743196c435