이 기사에서는 마우스를 따르고 기능을 닫는 이미지 광고에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드를 다음과 같이 복사하십시오.
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<title> 마우스를 따르고 기능이없는 사진 광고 </title>
<meta http-equiv = "content-type"content = "text/html; charset = gb2312">
</head>
<body>
<!-<body>와 </body>-> 사이에 다음 코드를 추가하십시오
<script type = "text/javaScript">
// <! [cdata [
기능 badad (html) {
var ad = document.body.appendChild (Document.CreateElement ( 'div'));
ad.style.csstext = "테두리 : 1px 고체 #000; 배경 : #fff; 위치 : 절대; 패딩 : 24px 4px 4px 4px; font : 12px/1.5 Verdana;";
ad.innerhtml = html || '이것은 나쁜 생각입니다!';
var c = ad.appendChild (document.createElement ( 'span'));
C.innerhtml = "×";
c.style.csstext = "위치 : 절대; 오른쪽 : 2px; 상단 : 2px; 커서 : 포인터";
c.onclick = function () {
document.onmouseMove = null;
this.parentnode.style.left = '-99999px'
};
document.onmouseMove = function (e) {
e = e || window.event;
var x = e.clientx, y = e.clienty;
settimeout (function () {
if (ad.Hover) 반환;
ad.style.left = x+5+'px';
ad.style.top = y+5+'px';
}, 120)
}
ad.onmouseOver = function () {
이 .hover = true
};
ad.onmouseout = function () {
이 .hover = false
}
}
badad ( '<img src = "/images/m02.jpg">')
//]]>
</스크립트>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.