网业特效是怎么做广告的?

发布时间:2024-11-02 21:27 发布:上海旅游网

问题描述:

当打开网业时,会看到一些会跟着鼠标走的广告!

问题解答:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>跟随鼠标的图片</title>
<script LANGUAGE="JavaScript">
var newtop=0
var newleft=0
if (navigator.appName == "Netscape") {
layerStyleRef="layer.";
layerRef="document.layers";
styleSwitch="";
}
else
{
layerStyleRef="layer.style.";
layerRef="document.all";
styleSwitch=".style";
}
function doMouseMove() {
layerName = 'iit'
eval('var curElement='+layerRef+'["'+layerName+'"]')
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"')
eval('curElement'+styleSwitch+'.visibility="visible"')
eval('newleft=document.body.clientWidth-curElement'+styleSwitch+'.pixelWidth')
eval('newtop=document.body.clientHeight-curElement'+styleSwitch+'.pixelHeight')
eval('height=curElement'+styleSwitch+'.height')
eval('width=curElement'+styleSwitch+'.width')
width=parseInt(width)
height=parseInt(height)
if (event.clientX > (document.body.clientWidth - 5 - width))
{
newleft=document.body.clientWidth + document.body.scrollLeft - 5 - width
}
else
{
newleft=document.body.scrollLeft + event.clientX
}
eval('curElement'+styleSwitch+'.pixelLeft=newleft')
if (event.clientY > (document.body.clientHeight - 5 - height))
{
newtop=document.body.clientHeight + document.body.scrollTop - 5 - height
}
else
{
newtop=document.body.scrollTop + event.clientY
}
eval('curElement'+styleSwitch+'.pixelTop=newtop')
}
document.onmousemove = doMouseMove;
</script>
</head>

<body>
<!-- 以下代码是设定此页的鼠标样式代码 -->
<script language="javascript">
if (navigator.appName == "Netscape") {
}
else
{
document.write('<div ID=OuterDiv>')
document.write('<img ID=iit src="images/flag.gif" STYLE="position:absolute;TOP:5pt;LEFT:5pt;Z-INDEX:10;visibility:hidden;">')
document.write('</div>')
}
</script>
</body>

</html>

或者
<html>
<head>
<title>跟随鼠标的图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body id="mybody" bgcolor="#FFFFFF" cellpadding="0"cellspacing="0" width="500" align="center">

<table width="520">
<tr>
<td align="left" width="512" valign="top">
<p align="center"></td>
<td align="left" valign="top" width="5"><script>
picFollow = new Image();
picFollow.src = "images/heart.gif";
picolimpic = new Image();
picolimpic.src = "images/love.gif";
document.onmousemove = getMousePosition;
document.onmouseout = pauseheart;
document.write("<div id=\"diva\" style=\"position:absolute\">");
document.write("<img name=\"pic\"src=" + picFollow.src + "></div>");
var picX = 20;
var picY = 100;
var step = 10;
var speed = 10;
var tolerance = step/2 +1;
var mouseX = 0;
var mouseY = 0;
var mouseOut = true;
var followMouse = false;
myInterval = setInterval('moveheart()', speed);
function pauseheart() {
mouseOut = true;
}
function getMousePosition(e) {
mouseX = window.event.x + document.body.scrollLeft;
mouseY = window.event.y + document.body.scrollTop;
mouseOut = false;
if (followMouse) {
diva.style.left = mouseX - pic.width / 2;
diva.style.top = mouseY - pic.height / 2;
}
}
function calcNewPos() {
if (mouseX == picX)
return;
arg = (mouseY-picY) / (mouseX-picX);
mult = 1;
if (mouseX - picX < 0)
mult = -1;
alpha = Math.atan(arg);
dx = mult * step * Math.cos(alpha);
dy = mult * step * Math.sin(alpha);
picX += dx;
picY += dy;
}
function collision() {
if ((Math.abs(picX-mouseX) < tolerance) && (Math.abs(picY-mouseY) <

tolerance) && (!mouseOut))
return true;
return false;
}
function moveheart() {
calcNewPos();
window.status = "("+mouseX+","+mouseY+")";
diva.style.left = picX - pic.width / 2;
diva.style.top = picY - pic.height / 2;
if (collision()) {
clearInterval(myInterval);
pic.src = picolimpic.src;
followMouse = true;
mybody.style.cursor="hand" }
}
</script></td>
</tr>
</table>
<table>
<tbody>
<script language="Javascript">
<!--
function selectAll(theField){
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
}
//-->
</script>

<table border="0" cellpadding="0" cellspacing="0" width="500"

align="center">
<tr>
</tr>
</table>

<table width="100%">
<tr>
</tr>
</table>

<table width="100%">
<tr>
</tr>
</table>
</body>

rem lil//

热点新闻