【发布时间】:2023-03-03 06:55:23
【问题描述】:
我想在某些操作后重定向到外部 url。请参考我的代码
this.http.get(this.apiurl+'api/insert.php?did='+this.did).subscribe(data=>{
var jsonData = data.json();
let url = jsonData.urlpass;
// redirect to this url like https://flipkart.com with my affilate params
window.open(url ,'_blank');
});
这个window.open(url ,'_blank'); 显示了弹出窗口阻止程序。
所以我就这样尝试
<a #myDiv id="anchorID" href="url here" target="_blank"></a>
$("#anchorID")[0].click();
但是这个点击事件并没有在订阅方法内部触发。
如果我使用var newWin = window.open();
newWin.location = url_pass;
它将错误创建为Cannot assign to 'location' because it is a constant or a read-only property.
我想在没有弹出阻止程序问题的情况下在新窗口中打开这个外部 URL。
请帮助任何人。
【问题讨论】:
-
Window open 期望 url 被传递...和 jQuery...你尝试过角度教程吗?
-
更新的答案对你有用吗??
标签: angular typescript