I preface this by saying that I am unfamiliar with Javascript in general. I have added some simple inline javascript to an HTML page to manipulate the URL based on a yes or no pop-up window.
The premise is simple. When the page loads there is a pop-up(function is called in the onload=) that asks the user to confirm their submission. If they hit yes, the page reloads the same URL, but with different URL parameters. It seems weird, but the application I am working with just prints HTML(The new parameter will prevent it from reloading the confirm pop-up). The code works on every browser I have tried(Chrome, Firefox, Opera, Edge), but it does not work in IE11. The confirmation pop-up never appears, it just renders the content normally. There are no errors.
I have made sure that the page allows javascript in Internet options
This is my URL format: myurl?conf=false
Here is my code:
function checkIfConfirmed() {
var url_string = window.location.href;
var url = new URL(url_string);
var isConfirmed = url.searchParams.get("conf");
if (isConfirmed == "false") {
confirmStatus(isConfirmed);
}
}
function setGetParameter(paramName, paramValue) {
var url = window.location.href;
var hash = location.hash;
url = url.replace(hash, '');
if (url.indexOf(paramName + "=") >= 0) {
var prefix = url.substring(0, url.indexOf(paramName + "="));
var suffix = url.substring(url.indexOf(paramName + "="));
suffix = suffix.substring(suffix.indexOf("=") + 1);
suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : "";
url = prefix + paramName + "=" + paramValue + suffix;
} else {
if (url.indexOf("?") < 0)
url += "?" + paramName + "=" + paramValue;
else
url += "&" + paramName + "=" + paramValue;
}
window.location.href = url + hash;
var xhr = new XMLHttpRequest();
xhr.open('GET', url + hash, true);
xhr.send();
}
function confirmStatus(isUnconfirmed) {
if (confirm("Are you sure you want to proceed?")) {
setGetParameter("conf", "true");
} else {
close();
}
}
<BODY onload="checkIfConfirmed()">
<!-- The content to be displayed -->
</BODY>