图片的onclick事件和图片的onmousemove事件不能同时执行
- <P><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A >http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>">
- <html xmlns="<A >http://www.w3.org/1999/xhtml</A>">
- <head>
- <title></title>
- <script type="text/javascript">
- document.onmousemove = initEvent;
- function initEvent() {
- var img = document.getElementById("img");
- img.onclick = imgOnClick;
- img.onmousemove = imgMouseMove;
- }
- function imgOnClick() {
- var img = document.getElementById("img");
- img.src = "/img/02.jpg";
- }
- function imgMouseMove() {
- var img = document.getElementById("img");
- var y = window.event.clientY;
- var x = window.event.clientX;
- if (x <= 681 && y <= 166) {
- img.src = "/img/lt.jpg";
- }
- else if (x <= 681 && y <= 316) {
- img.src = "/img/left.jpg";
- }
- else if (x <= 681 && y <= 466) {
- img.src = "/img/lb.jpg";
- }
- else if (x <= 906 && y <= 166) {
- img.src = "/img/rt.jpg";
- }
- else if (x <= 906 && y <= 316) {
- img.src = "/img/right.jpg";
- }
- else if (x <= 906 && y <= 466) {
- img.src = "/img/rb.jpg";
- }
- }
- </script>
- </head>
- <body>
- <p style="text-align:center;"><img src="/img/01.jpg" alt="" id="img" /></p>
- </body>
- </html>
- </P>
复制代码 |