代码之家  ›  专栏  ›  技术社区  ›  M Schenkel

脚本在YAHOO.util.Event.addListener处停止

yui
  •  0
  • M Schenkel  · 技术社区  · 14 年前

    我是新来的。只是想在我的网站上找到一个最基本的功能示例。

    代码如下:

        <button id="mytest">test</button>
    
        <script type="text/javascript">
        var helloWorld = function(e) {
                alert("Hello World!");
        }
        </script>
    
    
        <script type="text/javascript">
        alert('xx');
        YAHOO.util.Event.addListener("mytest", "click", helloWorld);
        alert('x2');
        </script>
    

    xx号 警报显示,但是 警觉永远不会。而且,单击按钮不会触发HelloWorld函数。

        <!-- Required CSS -->
        <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/progressbar/assets/skins/sam/progressbar.css">
    
        <!-- Dependency source file -->
        <script src = "http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom.event.js" ></script>
        <script src = "http://yui.yahooapis.com/2.8.1/build/element/element-min.js" ></script>
        <!-- Optional dependency source file -->
        <script src="http://yui.yahooapis.com/2.8.1/build/animation/animation-min.js" type="text/javascript"></script>
    
        <!-- ProgressBar source file -->
        <script src = "http://yui.yahooapis.com/2.8.1/build/progressbar/progressbar-min.js" ></script>
    
    3 回复  |  直到 14 年前
        1
  •  1
  •   Mr Lou    14 年前

    你应该确保js文件包含在你的html文件中,你写的代码就是你写的!

        2
  •  0
  •   M Schenkel    14 年前

    相信我找到了。或者至少我能找到其他有用的例子。但在我的例子中,我相信问题是我引用的js文件实际上并不存在。即此文件:

    http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom.event.js

        3
  •  0
  •   Satyam    14 年前

    当然,这是yahoo dash dom dash事件,而不是yahoo dash dom DOT事件