Este artigo descreve os anúncios de imagem que seguem o mouse e fecham a função. Compartilhe para sua referência. O método de implementação específico é o seguinte:
Copie o código da seguinte forma: <! Doctype html public "-// w3c // dtd xhtml 1.0 transitória // pt" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<título> anúncios de imagem que seguem o mouse e têm função desativada </ititle>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
</head>
<Body>
<!-Adicione o seguinte código entre <body> e </body>->
<script type = "text/javascript">
// <! [CDATA [
função badad (html) {
var ad = document.body.appendChild (document.createElement ('div'));
ad.style.csStext = "Border: 1px Solid #000; Antecedentes: #FFF; Posição: Absoluto; Preencidimento: 24px 4px 4px 4px; Font: 12px/1.5 Verdana;";
ad.innerhtml = html || 'Esta é a má ideia!';
var c = ad.appendChild (document.createElement ('span'));
c.innerhtml = "×";
c.style.csStext = "Posição: Absolute; direita: 2px; topo: 2px; cursor: ponteiro";
c.OnClick = function () {
document.onMousEmove = null;
this.parentnode.style.left = '-999999px'
};
document.onMousEmove = function (e) {
e = e || window.event;
var x = e.clientX, y = e.clienty;
setTimeout (function () {
if (ad.hover) retornar;
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 = "/imagens/m02.jpg">')
//]]>
</script>
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.