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

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

Frequently Asked Question #3

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

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 and versions 4.0 - 4.0.5, which inadvertently introduced related problems.

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/'",1,0,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/')",1,0,0]
  3. Loading a page into any frame (specifying a "target").
    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/'",1,0,0]

Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: June 26, 2001
Revised: October 8, 2003

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

Justtechjobs.comFind a programming school near you






Online Campus Both