0

Basically I have a table where if the user clicks on id it opens a link on new tab. So if user clicks on another id it should open on that earlier tab and not make another new tab

$scope.navigationUrl = function (event,item) {
 if (event.ctrlKey) {
  window.open('link' + item,"_blank"); // in new tab
    } else {
  $location.path('link' + item); // in same tab , yeah, this is completely wrong
    }
;
<tbody>

<tr ng-repeat="case in LastBuild">
 <td colspan="1" ng-click="navigationUrl($event,case.id)">{{case.id}}</td>
 <td colspan="1">{{case.TimeTaken}}</td>
</tr>

</tbody>

The ctrl+click works as it opens the link on new tab everytime. But how can i keep the same tab for just click ?

Daniel
  • 10,641
  • 12
  • 47
  • 85
matrixguy
  • 286
  • 1
  • 6
  • 30

2 Answers2

2

The window.open method has parameters:

window.open(URL,name,specs,replace)

If you define a name for a window, and use this on your javascript code, the named window will be replaced by the content.

Reference is here.

vaso123
  • 12,347
  • 4
  • 34
  • 64
0

You can use "_Parent" instead of "_blank" for this.

if (event.ctrlKey) {
        window.open('link' + item,"_Parent"); // in new tab
}

Hope it will help.

Pirate
  • 2,886
  • 4
  • 24
  • 42