PDA

View Full Version : confirm redirects but alert doesnt



vineet
07-09-2009, 10:25 AM
hi all

i am calling one function after another.

The below code shows a confirmation box and redirects to yahoo.com


<script type="text/javascript">
function todo(){
window.location="http://www.yahoo.com";
}
function conf(){
if(confirm("do you want to exit"))
{
todo();
}
}
</script>



Now instead of confirmation box if i show an alert box then the redirect doesnt works. why.



<script type="text/javascript">
function todo(){
window.location="http://www.yahoo.com";
}
function conf(){
if(alert("you are now going to exit"))
{
todo();
}
}



vineet

Jesdisciple
07-09-2009, 04:28 PM
alert returns undefined (i.e. nothing) and undefined == false.