How do I target a new Window or Frame when a user clicks on an Item?
Product Name: WebMenu for ASP.NET MVC
Product Version: 7.0
Document Type: Question
Last Updated: 4/23/2017
Document ID: 49

WebMenu does not use <A> tags for hyperlinks, so there is no property that reflects the TARGET attribute. Instead, WebMenu performs its navigation by using client-side JavaScript, namely the location.href property.

To provide the most flexibility to the page developer, the WebMenu Item object has an OnClick property. Use this property to provide client-side JavaScript code to execute when the Item is clicked. Use of this property overrides any value present in the URL property also available on the Item object.

To open a new window:

item.OnClick("window.open('http://www.domain.com/page', 'WindowName');")

To target a specific frame:

item.OnClick("top.{framename}.location.href = 'http://www.domain.com/page';")

Note that {framename} is the NAME attribute of the <FRAME> tag provided in the FRAMESET document that you created. This value may be case-sensitive.

Copyright © 2023 Coalesys, Inc. All Rights Reserved.