Web Analytics Made Easy -
StatCounter Top Navigational Bar II and External Links - CodingForum

Announcement

Collapse
No announcement yet.

Top Navigational Bar II and External Links

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Top Navigational Bar II and External Links

    Hello,

    I'm using Top Navigational Bar II within a frame (IndexFrame) to display local links in a different frame (TargetFrame). This is done via the syntax:

    dhtmlMenu.addItem(new NavBarMenuItem("Sprints", "javascriptarent.TargetFrame.location='/Coaching/sprints.html'"));

    My question is how do I get an external link to open a new window ? I can get the external links to show in either frame, but not call a new window.

    TIA,

    Ian

  • #2
    TopNavBarII Answers (lots of instructions/examples)

    FINALLY!
    I've been waiting too long for someone to ask about TopNavBarII. How old is this forum again? It's one of the few DHTML scripts with which I've had some decent experience. BrainJar is obviously your preferred responder, but I think I can handle this one.

    Now, for your particular issue, try the following:

    dhtmlMenu.addItem(new NavBarMenuItem("Your Text", "javascript:window.open('http://www.yahoo.com')"));

    .....
    ....
    ...
    ..
    .

    Now, I'm putting some additional comments/instructions below for anyone and everyone else who stumbles across this particular thread in their quest for TopNavBarII problems. I copied and edited the following from the original BrainJar.com web site...back when he had the instructions for this particular menu system "live". Enjoy...

    Top Navigational Bar II (By Mike Hall @ Brainjar.com)
    Last updated: 00/05/08
    Permission granted and modified by Dynamicdrive.com to include script in archive.
    For this and 100's more DHTML scripts, visit http://dynamicdrive.com

    Define menu items (first parameter of NavBarMenu specifies main category width, second specifies sub category width in pixels)
    Add more menus simply by adding more "blocks" of same code below

    NavBarMenu(hdrWidth, menuWidth) - Creates a new NavBarMenu object.
    The first value sets the width used for the header. If this is set to zero, the header will be sized to fit the text for it.
    The second value sets the width of the drop down menu. If this value is set to zero, it will be set to match the width of the header.

    addItem(item) - Adds an item to the menu. The given item must be a NavBarMenuItem object.
    The first item added to a menu will be used as the header displayed on the bar while the rest will appear in the
    drop down menu. You can add as many items as you want to the menu.

    NavBarMenuItem(text, link) - Creates a new NavBarMenuItem object with the given text and link.

    The text for a menu item can include simple HTML tags like <CENTER></CENTER> or <IMG> tags along with the plain text.
    The link can be one of three things: a URL, a null string ("") or a string of JavaScript code (any string beginning with "javascript:").

    For a URL, the link is loaded into the current window or frame when the item is clicked on. When a null string is specified,
    it creates a 'dead' link. Clicking on the item does nothing, but it will still be highlighted and if it is a header,
    the drop down menu will still appear when it is moused over.

    Menu items are not like normal HTML links (<A HREF="...">) so you cannot specify a target frame or window or event
    handlers like onmouseover. You can, however, use JavaScript code to achieve some of the same effects.

    Any link string that begins with "javascript:" is executed using the built-in eval() function when the item is clicked.
    This means that you can load pages in frames like this:
    new NavBarMenuItem("Table of Contents", "javascriptarent.frames['main'].location = 'toc.html'");
    Which loads the URL 'toc.html' into a frame called 'main'.

    You can open a link in a new browser window using the window.open() method. The code below produces the same
    result as using TARGET="_blank" in a link:
    new NavBarMenuItem("Table of Contents", "javascript:window.open('toc.html')");
    Don't know about the following, but...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.

    Various examples:
    -- text but no link...not clickable
    dhtmlMenu.addItem(new NavBarMenuItem("News", ""));

    -- link, takes over current page (no frames)
    dhtmlMenu.addItem(new NavBarMenuItem("CNN", "http://www.cnn.com"));

    -- link opens up in new browser window (for both frames and non-frames)
    dhtmlMenu.addItem(new NavBarMenuItem("Your Text", "javascript:window.open('http://www.yahoo.com')"));

    -- link opens up file on hard drive if available
    dhtmlMenu.addItem(new NavBarMenuItem("Your Text", "javascriptarent.frames['main'].location = 'file:///D:/\MainFolder/\Sub%20Folder/\sub-sub-folder/\page.htm'"));

    -- link opens up page in targeted frame of framed page
    dhtmlMenu.addItem(new NavBarMenuItem("<middle><img src='images/transparent_15x16.gif'> - PUT TEXT HERE</middle>", "javascriptarent.frames['main'].location = 'schedules/football.htm'"));

    -- link takes over current browser window of framed site
    dhtmlMenu.addItem(new NavBarMenuItem("PUT TEXT HERE", "javascriptarent.location = 'http://www.yahoo.com'"));


    I hope this has been helpful!
    Gordo
    "In the End, we will remember not the words of our enemies, but the silence of our friends."
    - Martin Luther King Jr. (1929-1968)

    Comment


    • #3
      Thanks

      Gordo,

      Yep you can handle this one.....Thanks Very Much, it worked a treat !

      Ian

      Comment

      Working...
      X