Is the browser setting problem

lieweffect's Avatar, Join Date: Apr 2006
Contributor
I write the following script:
Code: JavaScript
function confirmSubmit()
 {
 var agree=confirm("You are now leaving*the website and link to the third party website. Do you wish to continue?");
 if (agree)
     return true ;
 else
     return false ;
 }
It works, but some of my users said whenever they click 'Cancel' they still can link to other site.(In IE 7), but it function properly in other IE 7 in different computer.
(It work in properly in Opera)

So, may I know is the browser setting problem or the script problem?

Last edited by pradeep; 16Mar2007 at 14:48..
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Please post the code where you are calling this function!
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Code:
function confirmSubmit()
{
  var agree=confirm("You are now leaving*the website and link to the third party website. Do you wish to continue?");
   if (agree)
      return true ;
   else
     return false ;
 }
Note that you are expecting confirmSubmit to return true or false; if it is true, you return true, otherwise you return false. This action could just as well be coded by:
Code:
   return confirm ("blah blah blah");
which, in turn, could be replaced with confirm, and toss confirmSubmit entirely.

The problem, however, lies in the definition of true and false. I think you may solve your problem if you use the following:
Code:
if  (!confirm ("blah blah blah")) return false; else return true;