In the old days of webmasters, target attribute provided control of browsers’ behavior. Web sites were breaking natural flow of the user’s travel from site to site. Users couldn’t go back even if they wanted to and they had difficulties following relations between sites. But webmasters and site owners were afraid that users will forget about their web sites and it was better that the site resides somewhere in the background. The fear of the site owners was justified, as their sometimes pretty poor content couldn’t keep users focused and users often went away in search for relevant content.
Many internet-savvy people expected that the off-site link (link to some other web site) will open in new window. More than often too many windows covered their desktops, so internet-savvy people started using better browsers. Those had some advanced options and were able to give control over the browser back to users. In the mean time, the W3C, which already advised separation of structure, presentation and behavior in a web page, removed all traces of behavior layer from XHTML specs and forced webmasters to find other ways...
Contemporary web professionals use JavaScript to control behavior layer of a web document. Some authors wrote about how to place target attribute to links with DOM. Other authors provided option for a user to decide (examples: 1, 2). Some authors found ways to label links according to file type the link points at. It was a matter of time when some authors will innovate a way to add Open in New Window link after every link in a document.
The Open in New Window link points to the same URL like the original, default link,
but opens the page in a new window. It is created with DOM method document.createElement
, which is well known in DOM experts’
circles. Example of using this method could be found in this page’s source. If one would be more interested in other DOM methods and examples,
she would read some (if not all) of the following articles:
- Unobtrusive JavaScript
- DHTML Utopia: Modern Web Design Using JavaScript & DOM
- Client Side Coding : JavaScript & DHTML Tutorials
- DOM scripting Health and Safety
- JavaScript-enhanced image replacement
- Enhanced Form Widgets
- Reading out the “for” attribute via Javascript
- Fancy
<select>
s
Photo Frame by Mirko Beović.