JavaScript Tutorial/Development/debug

Материал из Web эксперт
Перейти к: навигация, поиск

Use alert dialog as a way to debug

<html>
<head>
<title>Debug Example</title>
<script type="text/javascript">
function myfunction() {
    alert("Entering function.");
    var iNumber1 = 5;
    var iNumber2 = 10;
    alert("Before calculation.");
    var iResult = iNumber1 + iNumber2;
    alert("After calculation.");
}
myfunction();

</script>
</head>
<body>
</body>
</html>


Write some messages to the Java console

<html>
<head>
<title>Debug Example</title>
<script type="text/javascript">
function test_function() {
    java.lang.System.out.println("Entering function.");
    var iNumber1 = 5;
    var iNumber2 = 10;
    java.lang.System.out.println("Before calculation.");
    var iResult = iNumber1 + iNumber2;
    java.lang.System.out.println("After calculation.");
    java.lang.System.out.println("Leaving function.");
}
test_function();

</script>
</head>
<body>
</body>
</html>