Im bored in class, practicing my scripting and I have run into a problem. I made this script, basically, its a computer strobe light. I had it fully automatic at first then I added the prompt so the user could change the speed and now I want them to be able to type quit in the prompt to close the window. Here is the HTML
I totally forget how to use If Else statements and I dont know if it is even close to being correct. If it takes too much work to add that would it be easier to add and onKeyPress to the body tag, like pressing 'Q' would close the window. Any help/suggestions would be appreciated.
Any help would be appreciated
Code:
<html>
<head><title>Strobe</title>
<script language="javascript">
<!--
var speed=prompt("Choose a speed in milliseconds (10 - Real Fast | 100 - Fast | 1000 - Slow)\nPress F5 to change speed or type quit to exit.","50")
bGrounds=new Array("black","white")
thisBG=0
bgColorCount=bGrounds.length
if(speed="quit") {
window.close
}
else{
function strobeBG() {
if(document.images) {
thisBG++
if(thisBG==bgColorCount) {
thisBG=0
}
document.bgColor=bGrounds[thisBG]
setTimeout("strobeBG()",3*+speed)
}
}
}
</script>
<style>
body {overflow:hidden}
</style>
</head>
<body onLoad="strobeBG()">
</body>
</html>
I totally forget how to use If Else statements and I dont know if it is even close to being correct. If it takes too much work to add that would it be easier to add and onKeyPress to the body tag, like pressing 'Q' would close the window. Any help/suggestions would be appreciated.
Any help would be appreciated