function checkPopupSupport() { // Try to open a small test popup window const popup = window.open("about:blank", "_blank", "width=1,height=1"); // If the popup is blocked, it will return null if (!popup) { return false; } else { // Popup was allowed, close it immediately popup.close(); return true; } } function setLocationHref(url) { window.location = url; } function saveSessionValue(key, value) { sessionStorage.setItem(key, value); } function getSessionValueAndRemoveIt(key) { const value = sessionStorage.getItem(key); sessionStorage.removeItem(key); return value; } function reloadWindow() { window.location.reload(); } function reloadWindowWithPath(path) { // If path is "/" and we are currently at http://localhost:3000/foo/bar, then we should redirect // to http://localhost:3000/ and not http://localhost:3000/foo/bar. If the URL is // https://my.domain.com/foo/bar, then we should redirect to https://my.domain.com/. const currentUrl = window.location.href; const currentPath = window.location.pathname; const currentPathLength = currentPath.length; const currentUrlLength = currentUrl.length; const newPath = currentUrl.substring(0, currentUrlLength - currentPathLength) + path; window.location.replace(newPath); } function consoleLog(msg) { window.console.log(msg); } function historyBack() { window.history.back(); }