Check whether the navigation pane is visible

You can use the following function to check whether the navigation pane in WebHelp is visible. The function returns true when the navigation pane is visible. The function returns false when the navigation pane is hidden or when the skin is not shown at all. The function GetTopicPane() is a support function that returns the topic frame as a resource.

To be able to use this script everywhere in your output, add both functions to whutils.js.

Usage

if(isnavpanevisible())
  //Do something if the navigation pane is visible

Script

function GetTopicPane() {//Get the topic pane
  var topicPane;
  if (top.frames[0].name == "ContentFrame")
    topicPane = top.frames[0].frames[1].frames[1];
  else
    topicPane = top.frames[1].frames[1];

  topicPane.focus();
  return topicPane;
}
function isnavpanevisible() {//Is navigation pane visible?

  var topicPane = GetTopicPane();

  if(isTopicOnly())
    return false;

  if(gbIE) {
    /*
      This method is for IE. IE doesn't correctly support clientWidth: it will allways return the body width even if a frame has a width of 0.
      Now we get the width of the frameset in the properties of the frameset.

      Note that this method only works for LTR help. If you use RTL help, you need to amend the colsetting compare to "*,0".
    */

  if(topicPane.parent.document.getElementsByTagName("FRAMESET")[0].getAttribute) {
    var colsetting = topicPane.parent.document.getElementsByTagName("FRAMESET")[0].getAttribute("cols");
  } else {
    var colsetting = topicPane.parent.document.getElementsByTagName("FRAMESET")[0].cols;
  }

  if(colsetting == "0,*")
    navpanewidth = 0;
  else
    navpanewidth = 1;

  } else {
    var navpanewidth = topicPane.parent.frames[0].document.body.clientWidth;
  }

  if(navpanewidth == 0)
    return false;
  else
    return true;
}

Tags: