0

I have research this for awhile now and I was not able to find a proper solution to this cause.

I have the code below...

<form name="userInfo" target="userInfo" onSubmit="window.open('', 'userInfo', 'width=650,height=463,location=no,toolbar=yes,menubar=yes,status=yes,resizable=yes,scrollbars=yes')" >
<input type="hidden" name="process" value="1"/>
<input type="hidden" name="key" value=""/>
<a href="javascript:submitUser();" class="BlueText"></a>
</form>

The above works fine in traditional html and popup blocker did not block the user submission.

However, I am trying to do this on an angular 2 and it opens a popup instead of new tab.

user.html

..
<button type="button" (click)="userReport(user.id)">
..

user.component.ts

userReport(id) {
doLogic(id);
this.windowOpen(id);
}

windowOpen(id) {
let actionUrl = this.getUrl(id); // this is a service
this.mapForm = document.createElement('form');
this.mapForm.target = userName;
this.mapForm.method = 'POST';
this.mapForm.action = actionUrl;
this.process = document.createElement('input');
this.process.setAttribute('type', 'hidden');
this.process.setAttribute('name', 'process');
this.process.setAttribute('value', '1');
this.mapForm.appendChild(this.process);
this.cookies = document.createElement('input');
this.cookies.setAttribute('type', 'hidden');
this.cookies.setAttribute('name', 'key');
this.cookies.setAttribute('value', this.key);
this.mapForm.appendChild(this.cookies);
document.body.appendChild(this.mapForm);
document.location.href = this.mapForm.submit();
window.open('', appName, 'width=630, height=535,status=yes,location=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes');
window.focus();
}

This above code in angular opens up a popup instead of new window (tab). Why is this the case? I dont see any difference between the original to the angular in terms of logic. Is there something I am missing?

logger
  • 1,983
  • 5
  • 31
  • 57
  • https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript – Randy Dec 17 '18 at 15:26

1 Answers1

0

You're oening in a new window with it:

window.open('', appName, 'width=630, height=535,status=yes,location=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes');

You must to adapt it to your code:

window.open('http://www.yourlink.com', '_blank');
Dharman
  • 30,962
  • 25
  • 85
  • 135
Luiggi
  • 358
  • 4
  • 12