<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Events !</title>
    <script type="text/javascript">
        window.onload = function() {
            document.getElementById('anImage').addEventListener('click', function() { alert('F-15 Tomcat'); }, false);
            document.getElementById('anImage').addEventListener('click', function() { alert('F-15 Tomcat again !'); }, false);
            document.getElementById('anImage').addEventListener('click',
                                               function() { Alert; }, 
                                               false);
        }
        function Alert() {
            alert('This is a Two Seater Aircraft .... !')
        }
    </script>
    <style type="text/css">
        #anImage
        {
            height: 275px;
            width: 357px;
        }
    </style>
</head>
<body>
   <img src="1012562.jpg" id="anImage" />
</body>
</html>

The Alert function is not being called in the third event .... !
Could anyone tell me what is wrong or a better way to call that function ????

Thanx

Member Avatar for stbuchok

Capitalization matters.

Alert != alert

also

alert != alert() // the brackets indicate that you are executing the function.

Capitalization matters.

Alert != alert

also

alert != alert() // the brackets indicate that you are executing the function.

Ok ok .....

I changed "Alert;" to "Alert();" !
Now it executes the way I wanted !

But then when I used only "Alert" ... why didn't it show any error ??
:O

Member Avatar for stbuchok

Because it's an allowable statement.

Also, don't create a function that is the same as another function but differs only by case. There is a built in alert function, by creating your own function called Alert, you are asking for trouble.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.