How to make a link open a new window

It is possible to make a link open a window by changing its target property. This can be done with a JavaScript snipet that iterates all the links and changes this property depending on the ID of the link.

The attached eSpace contains a WebBlock that does this for you. Just drag the WebBlock to a page, and all links that contain "_OpenWindow" in their name will be changed to open in a new window.

Please note that this only works with links with method Link. The eSpace contains some buttons and a link with method Submit that show you what occurs in each case.

In the example, the value of the link's target is set to "NewWindow". This means that a new window called "NewWindow" will open when you click the link. If you leave the "NewWindow" open and click another link that opens a window, the same window will be used for target.

This behavior can be changed by using special targets:
  • _blank: Always opens a new window

  • _parent: If you are using frames, uses the parent window

  • _self: Uses the current window

  • _top: If you are using frames, uses the top most window

To change the target, edit the expression in the WebBlock and change the portion market bold in the following code:

for (var i = 0; i<document.all.length; i++) {
if (document.all[i].id.indexOf('_OpenWindow')>0) {
document.all[i].target= 'NewWindow';

Now, with the new feature 'Extended properties', you can do it «cleaner»:
Specify the link's property 'TARGET' to open a new window.
No more need for unescaped expression!
The last solution provided by Olivier is much easier (and replaces the commonly used solution "")

One big advantage is that the input parameters are validated by the platform, so errors like wrong input parameters names, mandatory input params validation, data types are handled by the platform.

The drawback is that the window size is not preserved but even that it can be solved in the page onload event.