Loading Item Links in Frames and Windows

This example shows how to make the menu links open in different frames or in new windows.

Two frames are defined on this page, one called 'header' which contains the navigation bar and one called 'main' which starts with this page.

<html>
<head>
<title>NavBar Frames Example</title>
</head>

<frameset rows="100,*" border=0 frameborder="no" framespacing=0>
  <frame name="header" src="header.html" marginheight=0 marginwidth=0 scrolling=no>
  <frame name="main"   src="main.html">
</frameset>

</html>

The code to define the menu in the 'header' frame looks like this.

var bar = new NavBar(0);
var menu;

bar.setColors("#000000", "#ffffff", "#339933", "#000000", "#99cc99", "#000000", "#99cc99", "#ffffff", "#336633");
bar.setFonts("MS Sans Serif, sans-serif", "plain", "bold", "8pt", "MS Sans Serif, sans-serif", "plain", "bold", "8pt");
bar.setSizes(1, 4, 1);

menu = new NavBarMenu(100, 0);
menu.addItem(new NavBarMenuItem("Frames", ""));
menu.addItem(new NavBarMenuItem("Bottom Frame 1", "javascript:parent.frames['main'].location='blank.html'"));
menu.addItem(new NavBarMenuItem("Bottom Frame 2", "javascript:parent.frames['main'].location='main.html'"));
bar.addMenu(menu);

menu = new NavBarMenu(100, 0);
menu.addItem(new NavBarMenuItem("Windows", ""));
menu.addItem(new NavBarMenuItem("New Window 1", "javascript:window.open('blank.html')"));
menu.addItem(new NavBarMenuItem("New Window 2", "javascript:window.open('blank.html', '', 'width=300,height=200')"));
menu.addItem(new NavBarMenuItem("New Window 3", "javascript:window.open('blank.html', '', 'width=600,height=400')"));
bar.addMenu(menu);

menu = new NavBarMenu(100, 0);
menu.addItem(new NavBarMenuItem("Main Window", "javascript:window.top.location='frames.html'"));
menu.addItem(new NavBarMenuItem("Reload Frames", "javascript:window.top.location='frames.html'"));
menu.addItem(new NavBarMenuItem("Back", "javascript:window.top.location='index2.html#frames'"));
bar.addMenu(menu);

Note that you cannot use parent.frames[frame_name] for reserved target names like _blank or _top. Use window.open(...) or window.top.location='...' instead.