Debugging Using alert() Methods 'html' : Debug « Development « JavaScript DHTML






Debugging Using alert() Methods 'html'


<html>
<body>
<script language="JavaScript">
var myVariable;
var yourVariable;
   
function setType()
{
  alert("Inside the setType function.");  //Debug statement
  return(yourVariable="truck");
}
   
function setColor()
{
  alert("Inside the setColor function.");  //Debug statement
  return(myVariable="blue");
}
   
//Debug statement
alert("Before if statement: type="+yourVariable+" color="+myVariable);
   
if(setType() || setColor())
{
  //Debug statement
  alert("After if statement: type="+yourVariable+" color="+myVariable);
  document.write("The " + yourVariable + " is " + myVariable);
}
else
  alert("The vehicles could not be set");
   
</script>
   
</body>
</html>



           
       








Related examples in the same category

1.debug function displays plain-text debugging messages
2.Handle error
3.Debug function