Home > Enterprise >  How to Override new tab when grid row is clicked using javascript
How to Override new tab when grid row is clicked using javascript

Time:02-04

I Have a grid on first tab, when I click on first row , it opens new tab and first row details will be displayed , when I click on second row, already opened new tab should be overriden with second row details. How to do it using jQuery & JavaScript ?

Below is the code I am using currently and it is opening multiple new tabs instead of overriding.

window.open(_navUrl, '_blank','noreferrer',true);

CodePudding user response:

window.open(_navUrl, '_blank','noreferrer',true);

Well, your noreferrer value should be a unique referer, for example "tab1", "tab2", "tab3", ...

Then you could refer to it when opening your new window.

CodePudding user response:

The windowName parameter controls which window/tab is used.

https://developer.mozilla.org/en-US/docs/Web/API/Window/open

A DOMString specifying the name of the browsing context (window, or tab) into which to load the specified resource; if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName.

...

To open a new window on every call of window.open(), use the special value _blank for windowName.

So by using _blank each time, your explicitly saying, open a new window. Instead, use the same name each time, eg

window.open(_navUrl, 'gridtab','noreferrer',true);

then it will reuse the same window/tab.

  •  Tags:  
  • Related