Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript confirm is not working

I have one strange problem with javasctipt confirm method, whenever I call this, its throwing error like "Uncaught TypeError: Property 'confirm' of object [object Object] is not a function"

 var confirmVal = window.confirm("Please confirm?");
          if( confirmVal == true ){  

              return true;
          }

and my js files are in the html as like below

<link rel="stylesheet" href="css/vendor/bootstrap.min.css">    
<link rel="stylesheet" href="css/vendor/jquery-ui.css">


<script src="js/vendor/jquery-2.1.3.min.js"></script>
<script src="js/vendor/jquery-ui.js"></script> 


<link rel="stylesheet" href="css/vendor/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" href="css/vendor/star-rating.css">
<link rel="stylesheet" href="css/vendor/toastr.min.css">
<script type="text/javascript" src="cordova.js"></script> 
<script src="js/vendor/bootstrap.js"></script>
<script src="js/vendor/jquery.mobile-1.4.5.min.js"></script>
<script src="js/vendor/star-rating.min.js"></script>
<script type="text/javascript" src="js/vendor/toastr.min.js"></script>

Strange is, in my other html file its working fine.. Please help me, what am I doing wrong here..

like image 909
Mallikarjun Hampannavar Avatar asked Mar 28 '26 21:03

Mallikarjun Hampannavar


1 Answers

The code is correct except for the return statement which must be in a function.

function confirmation(){
  var confirmVal = window.confirm("Please confirm?");
      if( confirmVal == true ){  
          return true;
      }
  }
like image 95
Ikelie Cyril Avatar answered Mar 31 '26 13:03

Ikelie Cyril



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!