Using target="_top" in the Preview

In a link, the targets _top and _parent cause the link destination to be displayed in the parent frame of the current browser window. Since the Content Navigator from version 6.5 uses frames for the preview, following a link in the preview window may cause the menu or toolbar to become inaccessible.

This behavior can be avoided by adapting the content. Please add the following code to the layout which generates the HTML head and body sections:

<head>
  
  <npsobj condition="isEqual" name1="exportMode" value2="preview">
    <npsobj modifyvar="set" varname="adjustTargetsInPreview">adjustTargetsInPreview()</npsobj>
    <script type="text/javascript">
      function <npsobj insertvalue="var" name="adjustTargetsInPreview" />
      {
        var previewFrameName = "nps_browser_frame";
        var elements = document.getElementsByTagName('a');
        for (var i = 0; i < elements.length; i++) {
          var target = elements[i].target;
          if ("_top"==target || ("_parent"==target && previewFrameName == self.name)) {
            target = previewFrameName;
          }
          elements[i].target = target;
        }
      }
    </script>
  </npsobj>
  
</head>

<body onload="@{adjustTargetsInPreview}">
  
</body>

This script modifies link target values so that they never point outside the preview area.