I need to redirect to an external URL after a certain action. Here is my code:
this.http.get(this.apiurl+'api/insert.php?did='+this.did).subscribe(data=>{
var jsonData = data.json();
let url = jsonData.urlpass;
// I want to redirect to this URL like https://flipkart.com with my affiliate parameters
window.open(url ,'_blank');
});
The window.open(url ,'_blank');
function triggers the popup blocker.
To avoid this, I attempted the following approach:
<a #myDiv id="anchorID" href="url here" target="_blank"></a>
$("#anchorID")[0].click();
However, the click event does not get triggered within the subscribe method.
When I use
var newWin = window.open();
newWin.location = url_pass;
It results in an error:
Cannot assign to 'location' because it is a constant or a read-only property.
I am looking for a solution to open this external URL in a new window without encountering issues with the popup blocker.
If anyone can provide assistance, it would be greatly appreciated.