Adding event VML and HTML to VML makes it easy to add events to VML. All events in HTML can be applied to VML! The following example shows that when the mouse moves to the circle, the circle moves with the mouse. When the mouse clicks, the circle stops moving.
Script
Var canmove = false;
Function move ()
{
Circle. style. position = "absolute ";
Canmove = true;
Document. onmousemove = new Function ("if (canmove) {circle. style. posLeft = event. x; circle. style. posTop = event. y ;}");
}
Document. onclick = new Function ("canmove = false ");
Script
I don't know if you have noticed that the event area of VML is strictly in its own shape and is not like the image, but like a rectangle. By the way, we will introduce the Function object and use the Function object if the Function content is relatively small and the Function is called only once. The Function object can be used to create a Function object using new, the parameter is 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, the event can be controlled.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service