var x = document.getElementById("IMAGE1");
var userName = prompt("What is your name?", "Enter your name here.");
} while (userName == undefined);
alert("Sup," + userName);
<img id="IMAGE1" src="images/IMAGE1.jpg" alt="IMAGE1" style="cursorpointer"
Last edited by Ofekmeister; 09-09-2010 at 10:57 PM.
Thanks, Ofekmeister - using that code fixed my initial problem just fine.
I have, however, encountered a new problem - using Chrome and Firefox, I could not cancel out of the prompt like I was able to do before. Also, I had to change '= undefined' to '==null' or else it would always greet the user as 'undefined'.
Using IE8, ActiveX blocks the prompt from even appearing and I am told there is an error on the page down in the status bar at the bottom of the window.
My page is literally just a black and white image (IMAGE1) that when you click on it (onclick) it prompts you for your name then, as an alert, greets you and then IMAGE1 becomes IMAGE2 (a colored version of it).
Initially, I could have continued to be prompted for my name by clicking on the image, be it IMAGE1 (if you hit cancel on the prompt - this was fine) or IMAGE2 (if you entered a name and hit OK - which I did not want). I only wanted it to happen on IMAGE1 until a name was entered and IMAGE2 was displayed instead of IMAGE1.
I had sort of fixed the problem using "this.click" until I found that if you cancelled out of the prompt instead of typing a name and hitting OK, then you were stuck on IMAGE1 and could not re-click on IMAGE1 to be prompted for your name or see IMAGE2.
You fixed the issue of being able to click on IMAGE2 to be prompted for your name, thanks again.
Now, I cannot cancel out of the prompt and am forced to hit OK. So if someone accidentally clicks on the image, they must go forward with the prompt as it continues to pop up until OK is pressed. I still want the option of being able to cancel out of the prompt and re-click IMAGE1 to be prompted for a name.
In addition, IE8 does not even launch the prompt because the page loads with errors.
Sorry if I was unclear about this before - I appreciate the help