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

发布于 2024-09-10 13:26:07 字数 1332 浏览 0 评论 0原文

我是 YUI 新手。只是想在我的网站上获得一个最基本的功能示例。

代码如下:

    <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 警报显示,但 x2 警报从不显示。并且,单击该按钮不会触发 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>

I am new to YUI. Just trying to get a most basic functioning example working on my site.

Here is the code:

    <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>

The xx alert shows, but the x2 alert never does. And, clicking on the button does not fire the HelloWorld function.

I have the necessary include files:

    <!-- 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

并安 2024-09-17 13:26:07

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

you should be sure the js files are included on you html files,the code your write is write!

慢慢从新开始 2024-09-17 13:26:07

相信我找到了。或者至少我能够找到其他有效的例子。但就我而言,我认为问题是我引用的 js 文件实际上不存在。即这个文件:

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

Believe I found it. Or at least I was able to find other examples which worked. But in my case I believe the problem is the js files I was referencing in fact did not exist. Namely this file:

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

趁微风不噪 2024-09-17 13:26:07

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

sure, it is yahoo dash dom DASH event, not yahoo dash dom DOT event

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文