Dieser Artikel beschreibt die Bildanzeigen, die der Maus folgen und die Funktion schließen. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<title> Bildanzeigen, die der Maus folgen und die Funktion </title> haben
<meta http-äquiv = "content-type" content = "text/html; charSet = gb2312">
</head>
<body>
<!-Fügen Sie den folgenden Code zwischen <body> und </body>-> hinzu
<script type = "text/javaScript">
// <! [Cdata [
Funktion badad (html) {
var ad = document.body.AppendChild (document.createelement ('div'));
ad.style.csSTEXT = "Rand: 1px solide #000; Hintergrund: #fff; Position: absolut; Polster: 24px 4px 4px 4px; Schrift: 12px/1,5 Verdana;";
ad.innerhtml = html || 'das ist eine schlechte Idee!';
var c = ad.AppendChild (document.createelement ('span'));
C.innerhtml = "×";
C.Style.CSSTEXT = "Position: absolut; rechts: 2px; top: 2px; cursor: pointer";
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) return;
ad.style.left = x+5+'px';
ad.Style.top = y+5+'px';
}, 120)
}
ad.onmouseover = function () {
this.hover = true
};
ad.onmouseout = function () {
this.hover = false
}
}
badad ('<img src = "/bilder/m02.jpg">')
//]]>
</script>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.