UI Script for portal redirection not working if not opened in new window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 06:50 AM
Hi,
I have a scenario where the customer is transitioning from the old portals to the ESC portal.
In our Knowledge Base (KB) articles, catalog item descriptions, and other content, the old portal links are still being used. Revisiting and updating all these URLs is a massive task. Therefore, I am attempting to use a UI script for redirection and include it in the JS include of the portal theme record. Below is the UI script I am using:
(function () { var url = window.location.href; if (window.location.toString().indexOf('/sp?id=kb_view2') > 0) { alert('Redirecting to ESC'); url = url.replace('/sp?id=kb_view2', '/esc?id=esc_knowledge_home'); window.location.assign(url); } })();
The script above only triggers when the URL with /sp?id=kb_view2 is opened in a new tab or when the tab is refreshed. It does not work when clicking the Knowledge Base link within the portal.
Do you have any suggestions on how to achieve this redirection regardless of whether the link is opened in a new tab or clicked within the portal?