什么是“for”和“事件”脚本标记的属性(Javascript,HTML) [英] what are the "for" and "event" attributes of the script tag (Javascript,HTML)

查看:74
本文介绍了什么是“for”和“事件”脚本标记的属性(Javascript,HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个我在10年前编写的工作中继承的Web应用程序中,我注意到以下代码片断被重复使用:

In a web application I've inherited at work which was written about 10 years ago I've noticed the following code snippets repeatedly used:

<script language="JavaScript" for="FG1" event="Mousedown(Button, Shift, x, y)">
{
   // some code here that uses the variables Button, Shift, x and y
}
</script>

之前我从来没有见过这样的东西。 FG1是一个活动的x对象,所以这些是特殊的事情呢,或者它们只是处理任何常规JavaScript事件的另一种方式...... ID可以引用输入(例如按钮)并且事件是onclick?

I've never really seen anything like this before. FG1 is an active x object so are these some special things for it specifically or are they just another way of handling any regular javascript event...could the ID reference an input (e.g. a button) and the event be onclick?

理想情况下,我会把它写成(如果我的想法是正确的......我实际上并不会在Web应用程序中更改代码,因为它的工作原理,我只是)

ideally, i'd re write it as (if my thinking is correct...I'm not actually going to change the code in the web app as it works, i just want to understand what it means!)

<script type="text/javascript">
    var fg1 = document.getElementById("FG1");
    fg1.onMouseDown = function(Button, Shift, x, y) {
        // do stuff here...
    }
</script>


推荐答案

这些是Microsoft特定的(仅限Internet Explorer)对脚本标记的扩展,以及无需重写示例的冲动是一个很好的

Those are Microsoft-specific (Internet Explorer-only) extensions to the script tag, and your impulse to rewrite the example without them is a good one.

这篇关于什么是“for”和“事件”脚本标记的属性(Javascript,HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆