Incase you didn't know, if you have multiple links using target="_new" they will all re-use the same window, whereas the more commonly used target="_blank" will open a separate window each and every time.
From a code point of view, the target attribute is being phased out of HTML because it suggests behaviour, and we aim to keep the code for presentation, behaviour and content all separate.
JavaScript can be used instead - and should be as JavaScript is where behaviours are specified. (But don't shove it in the onclick attribute as that would not make it separate from the HTML!) You can set up a class for links that open new window, e.g. <a class="popup" href="www.example.com">link (opens in new window)</a>, then add javascript function to intercept link activations on those elements that have the relevant class. (note that this can easily be turned off or changed in the future without searching though all your code for the right links!)
From a usability point of view pop-ups are questionable, as many users can become confused. 'DHTML' layer pop-ups would be preferable, or even a 'modal dialogue' but the advantage of using the target attribute instead is most common browsers support it even when JavaScript is turned off.
The number one rule for all links:
Only use pop-ups where they make sense, are necessary and you can't think of a better way.
Rule number two:
Make sure you have a proper href so users can choose to over-ride your JavaScript.
|