Create dynamic link in top nav bar and open in new window

I have a web item in top nav bar which has a dynamic link .
It has to be opened in the new tab on clicking the web item.

Atlassian-plugin.xml


 <web-item key="xy-jump-to" name="Jump To" section="xy-menu/xy-menu-section-others" weight="10">
        <label key="Jump To Server"/>
        <link linkId="jump_to_id"/>
    </web-item>

And the js code goes like the below

AJS.toInit(function () {
		$("#jump_to_id").click(function (e) {
		e.preventDefault();
            AJS.$.ajax({
                    url:  AJS.contextPath()  + "/rest/integ/1.0/serverurl",
                    type: "GET",
                    contentType: "application/json",
                    processData: false,
                    success: function(result){
                     window.open(result.url,_blank);
                   	 }
		});
		});
		});

I found this approach via community on searching. It works perfect in my jira development server.
But When I uploaded the jar to a Jira Production instance. It is not working.and the current page is refreshed when the web item is clicked.

Please someone help me to solve this.I need to open a page in new tab when the top navigation bar web-item is clicked

I believe you can specify _blank as the window name in your call to window.open. See Window open() method.

1 Like

That is perfectly fine…My code already includes that. I forgot to mention it here. Now Edited the same.

But my question in different.

By Default, Web-item opens the link in the same window and it is the behavior of web-item. I need to change that opening the link in next tab.

How are you including the JavaScript snippet? Make sure it’s got the right context(Web fragment finder can tell you the context web resources on each page).

In your snippet _blank needs to be ‘_blank’.