تصف هذه المقالة إعلانات الصور التي تتبع الماوس وتغلق الوظيفة. شاركه للرجوع إليه. طريقة التنفيذ المحددة هي كما يلي:
انسخ الرمز على النحو التالي: <! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<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 ؛ الموضع: المطلق ؛ padding: 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 () {
إذا (ad.hover) العودة ؛
ad.style.left = x+5+'px' ؛
ad.style.top = y+5+'px' ؛
} ، 120)
}
ad.onmouseover = function () {
this.hover = صحيح
} ؛
ad.onmouseout = function () {
this.hover = خطأ
}
}
badad ('<img src = "/images/m02.jpg">')
//]]>
</script>
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.