Reputation: 13
I'm writing because of some functionality on my website using JavaScript.
I'm using an alert
pop-up to ask if the user wants to leave the domain, and it has the 'Prevent this page from creating additional dialogs' checkbox because i'm using Chrome. If it is checked and I run the script, it defaults to the "Cancel" option which is currently an window.location.href = '#';
command, which functionally does "nothing" to the user. I'm wondering if there is a workaround that defaults it to the "OK" option(which re-links the user to the other domain).
Here is my code:
<button onclick="myFunction()">Fan-Made Website</button><script> function myFunction() {
var x;
if (confirm('You are leaving the main domain to the fan-made website. Do you wish to proceed\?') == true) {
window.location.href = 'mydomain';
} else {
window.location.href = '#';
}
document.getElementById("demo").innerHTML = x;
}
Upvotes: 0
Views: 162
Reputation: 860
The browser will not allow you to change this as its purpose is to prevent a developer like you from making this decision for the user.
Upvotes: 2