DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #6 - dhtmlab.com | WebReference

DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #6 - dhtmlab.com

Frequently Asked Question #6

Entered: Feb 15, 1999

When I use the menus in a frameset, there are some links which I would like to mark so that they break the frameset, loading into the full window. What can I do?

or

Some of the pages my items link to need to appear in a new window. Can I do this from the menu script?

or

In a multi-frame frameset document, I don't always want the linked-to pages to appear in the "main" frame, but in a third or fourth frame off the main frameset. Can I do this?

or

How can I specify a target for the menu item links, like I do in the A tag with TARGET= attribute?


All the questions, above, have an answer that relates to the same powerful, but seldom used feature of the menus: The ability to include a javascript: URL in the menu arrays. Any JavaScript statement or function call can be used in place of an https:// URL. This gives you the ability to have a menu link do...anything!

This feature was introduced and discussed in detail in version 2.1.

IMPORTANT NOTE: All versions since version 2.1 are compatible, with the exception of version 3.05, which inadvertently introduced a related problem.

Let's illustrate the use of javascript: URLs by answering the questions above directly. For the sake of the examples, we'll assume that you want to link to DHTML Lab.

  1. Loading a page into the full window.
    Assign the URL to the location property of the JavaScript top object, which represents the full window:
    "My Favorite DHTML Site","javascript:top.location='https://www.dhtmlab.com/'",0,
  2. Loading a page into a new window.
    Use the window.open() method, placing the URL as the first argument. You may also specify any of the other arguments of the open() method:
    "My Favorite DHTML Site","javascript:window.open('https://www.dhtmlab.com/')",0,
  3. Loading a page into any frame.
    Like the first example, we can assign the URL to the location property of any frame. If you have a frame built with a NAME= attribute value of seventhFrame (<FRAME NAME="seventhFrame">), and you want a linked-to page to appear in it, then the JavaScript statement in your array would be:
    "My Favorite DHTML Site","javascript:top.seventhFrame.location='https://www.dhtmlab.com/'",0,
  4. Specifying a target.
    The default target frame is, of course, specified by the mainFrName parameter, introduced in version 1, column 18. Other targets can be specified using the methods illustrated above.

Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Dec 29, 1998
Revised: June 26, 2001

URL: https://www.webreference.com/dhtml/hiermenus/version3/faq/faq6.html

Justtechjobs.comFind a programming school near you






Online Campus Both