Main Menu
Starting with the Main menu, I reviewed the standard JavaScript, and traced the code to a function called menu_callback in menu.js as shown below :Looking at the source of this JavaScript function, we can see that is does take a second parameter to indicate which window to open the link in, which is passed onto the openURL function :
However, the population of this JavaScript parameter is not possible directly from the ActiveView Override itself, as the option is not exposed in the current implmentation, so we have to get a little creative. Looking at the format of the HTML I decided to try adding in a partially formatted string to create the appropriate output in the HTML to push a window name into the second parameter of the call (this does result in the current second parameter in the function call provided by the WebLingo being pushed to third in the function - see MDN for how JavaScript handles this. Using this approach we have the following ActiveView Override :
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<override type="topmenu">
<commands menutype="Personal">
[// Add a new command to the Personal menu and place in position 2
<addcommand newcmd="Google" neworder="2" newurl="http://google.com','new"/>
</commands>
</override>
</overrides>
Add Item Menu
The next override location to look at is the Add Item menu, again a choice of window is supported in the underlying JavaScript method that is called openURL in ajax_dhtml_util.js, which is the same function called by menu_callback above, as shown in the following screenshot :Tracing the population of this HTML back, we end up in the webnode\html\additemcomponent.html file which iterates through the available options and in our case calls the nm_AddNewMenuItemWithUrl function in menu.js which creates the JavaScript for each menu item, and this does not support a standalone window parameter. Thus, we need to tweak the URL parameter to this call so that its passed directly through to the openURL function as shown below :
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<override type="additem">
<commands>
[// Example of adding a Google item and placing it in position 1 of the list
<additem newItem="Google" newOrder="1" newImg="[LL_REPTAG_SUPPORTDIR /]2-guys.gif"r/>newURL="http://www.google.ca\',\'new" />
</commands>
</override>
</overrides>
Function Menu
The final override location is the function menu override, looking at the JavaScript that populates the menu is popup_callback in menu.js and its functional definition indicates that it does support a window parameter function popup_callback( theURL, theTarget ) :Again, ActiveView does not support a parameter being passed directly for this JavaScript parameter. A similar approach used above does not work in this case as the URL is encoded as its passed through the various JavaScript functions resulting in the loss of our tweak to insert the additional parameter, so a different approach is needed. Looking at the WebLingo that creates the page, webnode\html\functionsmenu2.html, the property openInNewTab is set as each command is processed in a loop in that WebLingo file ;openInNewTab = data.openInNewTab and this determines if a new window is used or not :
Tracing further back, the openInNewTab property is part of the WebNodeCommand object, which by default returns the value of the object's .fOpenInNewTab property which is a Boolean.
As we are overriding via ActiveView, which is at a higher level of abstraction, we cant set this property, nor do we have a similar ActiveView parameter that we can populate for new menu items, therefore we move back to seeing what can be achieved by pushing an amended value for the URL parameter through from the ActiveView.
The URL can use the javascript: handler so we are able to set the URL value to javascript:alert("hello world") which shows the message box (assuming Javascript in the address bar is enabled in your browser) :
<addcommand newcmd="Run WebReport" neworder="1" newurl="javascript:alert('hello');" newParent="Main" />
<addcommand newcmd="Run WebReport" neworder="1" newurl="javascript:window.open('https://www.greggriffiths.org/livelink/','newwin');" newParent="Main" />
If you are interested in getting support for setting a new window into the product, then please support the OpenText Feature Request LLWR-16076.
Conclusion
Using some simple HTML and JavaScript tricks its possible to have items added via an ActiveView Override open in a different browser window to provide those working with ActiveViews as a way to customise the user interface for their user communities a method to have links open in a new window / tab if required.