Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirm box and firefox

Status
Not open for further replies.

jtaylorttt

Programmer
Mar 3, 2005
24
US
I have some javascript that puts up a confirm box. after the confirm box, depending on if they selected ok/cancel I display a alert.

under ie this works fine, under the latest firefox 1.5.0.7. I get the box and then it seems to exit and does not get to the alert.

any ideas?

if (confirm("Are you sure you wish to APPROVE this property?") == false)
{
alert('said no');
return;
}

alert('said yes');
 
try this..
Code:
if (!confirm("Are you sure you wish to APPROVE this property?"))
{
  alert('said no');
    return;
}        
else{alert('said yes');}


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
could it be anything to do with doctype or the lack of doctype I have on my page
 
how about the long way..
Code:
var answer = confirm("Are you sure you wish to APPROVE this property?");

if(answer == 0){
  alert("said no");
    return false;
}        
else{alert("said yes");
    return true;}


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
anything's possible. more than likely has to do with your javascript. this worked perfectly for me in IE and firefox:

Code:
<script type="text/javascript"><!--

if ( !confirm( 'blah?' ) ) {
    alert('did not say yes');
} else {
    alert('said yes');
}

//--></script>

so i have a feeling something else is happening that you aren't expecting.



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
yup - i concurr, I just did the following and works fine for I.E & FF
Code:
<html>
<head>
<script>
function showme(){
    answer = confirm("Are you sure you wish to APPROVE this property?");

    if(!answer){
        alert('said no');
        return false;
    }        
    else{
        alert('said yes');
        return true;    
    }
}
</script>
</head>
<body onload="showme();">

</body>
</html>

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
that works. so it is not the confirm itself. but for the life of me, I can not figure out why it is dropping out of my code. thanks
 
Check the Javascript console in Firefox to see if it catches any errors.

If you have the code posted at a URL, give us that, or at least provide more of your JS so we can see what's going on. Be sure to copy and paste, don't type it in fresh.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top