The close combination of VML and HTML makes it easy to add events to VML. All events in HTML can be applied to the middle of VML! The following example is a demonstration: When the mouse moves to a circle, the circle moves with the mouse. When the mouse clicks, the circle stops moving.
I don’t know if you have noticed that the VML event area is strictly in its shape, not all rectangles like the picture. By the way, let’s introduce the Function object. Use Function object. If the function has a relatively small content and is called once, you can use the Function object. The method is to use new to create a Function object, and the parameters are the content of the function. A better way to control events is to use a global variable. The execution of an event depends on a global variable, and another event can set this global variable, so that events can control events.
<v:oval style="position:relative;width:100;height:80;" onmouseover="move()" fillcolor=red />
<script>
var canmove=false;
function move()
{
="absolute";
canmove=true;
=new Function("if(canmove){=;=;}");
}
=new Function("canmove=false");
</script>
<script>
var canmove=false;
function move()
{
="absolute";
canmove=true;
=new Function("if(canmove){=;=;}");
}
=new Function("canmove=false");
</script>
I don’t know if you have noticed that the VML event area is strictly in its shape, not all rectangles like the picture. By the way, let’s introduce the Function object. Use Function object. If the function has a relatively small content and is called once, you can use the Function object. The method is to use new to create a Function object, and the parameters are the content of the function. A better way to control events is to use a global variable. The execution of an event depends on a global variable, and another event can set this global variable, so that events can control events.