(1)点击事件写法如下,这里会先显示文本,点击之后弹出对话框。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning">My name is Burning</p>
        <script type="text/javascript">
        window.onload = function(){
            var bur = document.getElementById("Burning");
            bur.onclick = Hello;

            function Hello(){


                alert("Hello world");
            }
        }   
        </script>
    </body>
</html>

(2)这样些会首先弹出对话框,然后显示文本。这个的原因百度了一下,没懂!

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning">My name is Burning</p>
        <script type="text/javascript">
        window.onload = function(){
            var bur = document.getElementById("Burning");
            bur.onclick = Hello();

            function Hello(){


                alert("Hello world");
            }
        }   
        </script>
    </body>
</html>

(4)这里会先显示文本,点击之后弹出对话框。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning" onclick="Hello()">My name is Burning</p>
        <script type="text/javascript">

            //var bur = document.getElementById("Burning");
            //bur.onclick = Hello();
            /*if (typeof Hello == "function"){
                console.log("right");
            }*/
            function Hello(){


                alert("Hello world");
            }

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

(5)只显示文本,点击事件不好使。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning" onclick="Hello">My name is Burning</p>
        <script type="text/javascript">

            //var bur = document.getElementById("Burning");
            //bur.onclick = Hello();
            /*if (typeof Hello == "function"){
                console.log("right");
            }*/
            function Hello(){


                alert("Hello world");
            }

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

(6)同(1)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning">My name is Burning</p>
        <script type="text/javascript">
        window.onload = function(){
            var bur = document.getElementById("Burning");
            console.log(bur);
            bur.onclick = function(){
            /*if (typeof Hello == "function"){
                console.log("right");
            }*/


                alert("Hello world");
            };
        }

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

(7)同(2)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning">My name is Burning</p>
        <script type="text/javascript">
        window.onload = function(){
            var bur = document.getElementById("Burning");
            console.log(bur);
            bur.onclick = function(){
            /*if (typeof Hello == "function"){
                console.log("right");
            }*/


                alert("Hello world");
            }();
        }

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

一段小代码:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>test for function</title>
    </head>
    <body>
        <p id="Burning">My name is Burning</p>
        <script type="text/javascript">
        window.onload = function(){
            var bur = document.getElementById("Burning");
            console.log(bur);
            //bur.onclick = Hello;
            if (typeof Hello() == 'function')
            {
                console.log("Hello world");
            }//typeof Hello()会执行Hello程序
            function Hello(){
                alert("Hello world");
            }
        }

        </script>
    </body>
</html