1. when to do it
It is quite common for web links to open not in the current window, but a new window. Throughout this site this technique has been used to open external links, which always open in the same second window: like this link to the Leeds University site.
The advantage of doing this is, mainly, that you can give the visitor access to an external link but without their leaving your site. They will have to return there at some point, even if only to close the window. At first glance, then, this addresses one reason people might feel reticent about placing external links on their site.
In a crude way, it's also a way to present more than one text on screen at the same time - something noted as a kind of linking theme in this lecture. On this site it is generally the case that the second window, if it's being used, is showing an external link or a demonstrative page that is directly related to the topic being looked at, back in the original window. Users can flick between them as they wish.
Don't overdo this, however. Leaving a user with 27 browser windows open at the end of a session is rather impolite - it's like going into their office, messing things up and leaving them to clear up behind you. It also breaks the "flow" of the Back button (a new window will open with no "history", as if it is a new browser session). Remember that it is possible for a user to choose to open a link in a new window (in IE you can press Shift as you click on a link, or select an option from the right-click menu). Ultimately, it is their desktop, and you are best leaving it to them to decide. However, there may be times when you want or need to do it and as long as you do so with discretion, you should be fine.
|
2. how to do it
The simplest way is through the target attribute. Take the following link:
<a href="newpage.html">Open the new page</a>
Adding the following to a link will always cause that link to open in a new window (do ensure you include the _, or underscore character - it's to the left of the zero on the keyboard, above the hyphen):
<a href="newpage.html" target="_blank">Open the new page</a>
However, it is also possible to name the new window. This is done by putting something else - without an underscore - in the target attribute. For example, all the links on this site which open a new window look like this:
<a href="newpage.html" target="sample">Open the new page</a>
If only the original window is open and a browser sees that it will open a new window and name it "sample". Then, all subsequent links which include target="sample" will open in that window, so only two windows will be open at any one time.
Another way to open new windows, and to gain a bit more control over their size and position, is to use JavaScript. This was mentioned back in lecture 8 - also see the online teaching materials on this topic.
|