Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the "for" and "event" attributes of the script tag (Javascript,HTML)

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>

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?

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>
like image 879
davidsleeps Avatar asked Oct 12 '09 23:10

davidsleeps


People also ask

What are the two attributes of script tag?

Attributes: Many attribute associated with script tag. async: It is used to specify the script is executed asynchronously. charset: It is used to specify the character encoding used in an external script file. defer: It is used to specify that the script is executed when the page has finished parsing.

What is script for in HTML?

<script>: The Script element. The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.


1 Answers

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.

like image 56
Jonathan Feinberg Avatar answered Nov 15 '22 16:11

Jonathan Feinberg