Forum Moderators: open
Textbox's onfocus event is set as follows where Show Prompt displays the actual alert box:
onfocus="ShowPrompt();"
ShowPrompt has nothing but a simple alert statement in it ==>> alert("hello world");
Code runs as expected in IE but behaves abnormally in Firefox! In Firefox, it keep popping up the alert box as if I am calling the ShowPrompt method in a loop! this does not occur on IE and IE displays the alert box only once!
What I might be doing wrong here? or how to make Firefox alert a message only once? any insights?
Thanks,
Manny
It almost sounds like the browser is treating the popup as an object so that when you dismiss the popup, it resets focus to the textbox, refiring the function etc.,
What about something like this?
<script type="text/javascript">
<!--
//global var to hold ref to last object blurred
var lastObj=''
//sets lastObj to the object that was blurred
function setLastObj(obj){
lastObj=obj
}
//checks to see if current object is the same as
//the last blurred object--if so, no popup
function showAlert(obj){
if (obj!=lastObj){
alert('Hello World!')
}
}
//-->
</script>
<style type="text/css">
</style>
</head>
<body>
<input id="txtA" onfocus="showAlert(this)" onblur="setLastObj(this)" />
I don't have linux so can't prove that this will work, but it might be worth a shot...
ajkimoto