-4

I am trying to make a joke website and I want to be able to close or exit the website if the user answers yes to being a basket case.....

var basket = prompt("are you a basket case?");
var vegtables = prompt("How many times do you eat vegtables at least  once a day in a week?");
if (basket === "yes")
{
window.close();
}

if (parseInt(workOut) >= 5) {
alert("Good job! Keep it up")
}
else {
alert("Looks like there is room for improvement, visit my fitness page")
}

if (parseInt(vegtables) >= 6) {
("Good job! keep it up!")
}
else {
alert("You need to eat more vegtables, visit my health and reboot pages!")
 }
marcusv
  • 5
  • 5

2 Answers2

-1

below script will only work in Firefox.if we enable the settings allow_scripts_to_close_windows.

For that

1.Open FireFox

2.Enter about:config in Address bar

3.It will open a Config page of Firefox

4.Search allow_scripts_to_close_windows

5.It will show allow_scripts_to_close_windows.by default value will be false.To enable double click on the allow_scripts_to_close_windows row.It will change to true

6.Close Firefox

Then execute the below script.

<script>
var basket = prompt("are you a basket case (yes/no) ?");


if (basket === "yes")
{
    window.close()
}
var vegtables = prompt("How many times do you eat vegtables at least once a day in a week ?");
if (parseInt(vegtables) >= 6) {
    alert("Good job! keep it up!")   
}
else {
    alert("You need to eat more vegtables, visit my health and reboot pages!")
}

</script>
-2
window.close();

instead of

window.closeCurrentWindow();

and because you said in a comment you are using firefox, you can change settings, go to url about:config,

change to this value-

dom.allow_scripts_to_close_windows = true
Erez
  • 42
  • 5