I am trying to redirect IE users to Edge since IE is retiring.
My website is built by Angular 7 and I put this code in ngOnInit()
const ua = window.navigator.userAgent;
if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident") > 0) {
window.location.href = "microsoft-edge:" + window.location.href;
setTimeout(function () {
window.location.href = "https://support.microsoft.com/zh-tw/office/%E9%80%99%E5%80%8B%E7%B6%B2%E7%AB%99%E5%9C%A8-internet-explorer-%E4%B8%AD%E7%84%A1%E6%B3%95%E4%BD%BF%E7%94%A8-8f5fc675-cd47-414c-9535-12821ddfc554";
}, 0);
}
My steps:
Open IE and type http://localhost:4200/index into the URL bar
→ IE window: redirect to Microsoft support page
→ new Edge window open with http://localhost:4200/index
Close Edge window and keep IE window open and retype http://localhost:4200/index into IE
→ IE window: redirect to Microsoft support page
→ no Edge window open
But if I close both IE window and Edge window and open a new IE window and do the whole thing again, it works fine.
Version Info
Does anyone know why and how can I fix it?