Open menu item in new tab using Menu control.

Hello Everyone,

I am using Syncfusion EJ2 JavaScript control for my project. I am trying the "Menu Bar" control.

https://ej2.syncfusion.com/javascript/documentation/menu/es5-getting-started

https://ej2.syncfusion.com/javascript/documentation/api/menu/

In the documentation I understand that I should specify target: "_blank" if I would want the menu page to open in a new tab/window.

Here is how I have specified the menus in my page -

Image_1126_1702309983228

When page is rendered, I do see that target property of the menu item is _blank. But upon selecting the menu item, the page still opens in current window.

Image_9911_1702309997148

Here is the HTML of the menu item that gets generated from the above menu object. Looks like the target property is not getting passed.


<div class="e-menu-wrapper e-menu-popup e-lib e-popup e-control top-nav-dropdown e-keyboard e-popup-open" id="menuitem_5-ej2menu-navigation-popup" style="left: 353.561px; top: 51.995px; z-index: 1001;">

   <ul class="e-menu-parent e-ul " role="menu" tabindex="0">

      <li class="e-menu-item e-navigable" id="menuitem_6" role="menuitem" data-value="null" tabindex="-1" aria-label="Invoices">

         <a class="e-menu-text e-menu-url" rel='nofollow' href="http://localhost:7576/billing/invoices/">

            <div class="e-anchor-wrap">Invoices</div>

         </a>

      </li>

      <li class="e-menu-item e-navigable e-focused" id="menuitem_7" role="menuitem" data-value="null" tabindex="-1" aria-label="New Invoice Payment">

         <a class="e-menu-text e-menu-url" rel='nofollow' href="https://www.google.com/">

            <div class="e-anchor-wrap">New Invoice Payment</div>

         </a>

      </li>

   </ul>

</div>


Is there anything I may be missing here?


3 Replies

KV Keerthikaran Venkatachalam Syncfusion Team December 12, 2023 06:47 AM UTC

Hi Pawan,


We checked the reported query, and by using the beforeItemRender event of the menu, you can open the link in a new tab. Please refer to the below UG.


UG link: https://ej2.syncfusion.com/javascript/documentation/menu/icons-and-sub-menu-items#navigation


Please let us know if you need any further assistance on this.


Regards,

KeerthiKaran K V



PS Pawan Singh replied to Keerthikaran Venkatachalam December 12, 2023 04:36 PM UTC

Thank you for responding and confirming. Apparently we were suppressing the target attribute through an old code. Thank you for your clarification. 



KV Keerthikaran Venkatachalam Syncfusion Team December 13, 2023 04:06 AM UTC

You're welcome, Pawan. Get back to us if you need any other assistance.

NOTE: If that post is helpful, please mark it as an answer so that other members can locate it more quickly.


Loader.
Up arrow icon