原文发布时间为:2008-11-08 —— 来源于本人的百度文章 [由搬家工具导入]
浮动广告可以用层和时间轴结合做出,先选择你的dreamweaver“窗口”,然后从“窗口”菜单中选择“时间轴”,时间轴就会出现在dw下方,再用层工具在网页中拖一个层,在层中插入你的广告内容,再把层拖到时间轴上,在把层拉到其他地方,再把层拖到时间轴上,再录制一个层路径,在网页上拖出你想要图象漂移的路径就可以了。
产生的代码如下:<html>
<head>
<title>js</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
115px;
height:99px;
z-index:1;
left: 551px;
top: 207px;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_timelineGoto(tmLnName, fNew, numGotos) { //v2.0
//Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved.
var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,lastKeyFr,propNum,theObj;
if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
tmLn = document.MM_Time[tmLnName];
if (numGotos != null)
if (tmLn.gotoCount == null) tmLn.gotoCount = 1;
else if (tmLn.gotoCount++ >= numGotos) {tmLn.gotoCount=0; return}
jmpFwd = (fNew > tmLn.curFrame);
for (i = 0; i < tmLn.length; i++) {
sprite = (jmpFwd)? tmLn[i] : tmLn[(tmLn.length-1)-i]; //count bkwds if jumping back
if (sprite.charAt(0) == "s") {
numKeyFr = sprite.keyFrames.length;
firstKeyFr = sprite.keyFrames[0];
lastKeyFr = sprite.keyFrames[numKeyFr - 1];
if ((jmpFwd && fNew<firstKeyFr) || (!jmpFwd && lastKeyFr<fNew)) continue; //skip if untouchd
for (keyFrm=1; keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]; keyFrm++);
for (j=0; j<sprite.values.length; j++) {
props = sprite.values[j];
if (numKeyFr == props.length) propNum = keyFrm-1 //keyframes only
else propNum = Math.min(Math.max(0,fNew-firstKeyFr),props.length-1); //or keep in legal range
if (sprite.obj != null) {
if (props.prop2 == null) sprite.obj[props.prop] = props[propNum];
else sprite.obj[props.prop2][props.prop] = props[propNum];
} }
} else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);
}
tmLn.curFrame = fNew;
if (tmLn.ID == 0) eval('MM_timelinePlay(tmLnName)');
}
function MM_timelinePlay(tmLnName, myID) { //v1.2
//Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved.
var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;
if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
tmLn = document.MM_Time[tmLnName];
if (myID == null) { myID = ++tmLn.ID; firstTime=true;}//if new call, incr ID
if (myID == tmLn.ID) { //if Im newest
setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
fNew = ++tmLn.curFrame;
for (i=0; i<tmLn.length; i++) {
sprite = tmLn[i];
if (sprite.charAt(0) == 's') {
if (sprite.obj) {
numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {//in range
keyFrm=1;
for (j=0; j<sprite.values.length; j++) {
props = sprite.values[j];
if (numKeyFr != props.length) {
if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];
else sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];
} else {
while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;
if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];
else sprite.obj[props.prop2][props.prop] = props[keyFrm-1];
} } } } }
} else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);
if (fNew > tmLn.lastFrame) tmLn.ID = 0;
} }
}
function MM_initTimelines() { //v4.0
//MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.
var ns = navigator.appName == "Netscape";
var ns4 = (ns && parseInt(navigator.appVersion) == 4);
var ns5 = (ns && parseInt(navigator.appVersion) > 4);
var macIE5 = (navigator.platform ? (navigator.platform == "MacPPC") : false) && (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
document.MM_Time = new Array(1);
document.MM_Time[0] = new Array(5);
document.MM_Time["Timeline1"] = document.MM_Time[0];
document.MM_Time[0].MM_Name = "Timeline1";
document.MM_Time[0].fps = 15;
document.MM_Time[0][0] = new String("sprite");
document.MM_Time[0][0].slot = 1;
if (ns4)
document.MM_Time[0][0].obj = document["Layer1"];
else if (ns5)
document.MM_Time[0][0].obj = document.getElementById("Layer1");
else
document.MM_Time[0][0].obj = document.all ? document.all["Layer1"] : null;
document.MM_Time[0][0].keyFrames = new Array(1, 15);
document.MM_Time[0][0].values = new Array(2);
if (ns5 || macIE5)
document.MM_Time[0][0].values[0] = new Array("485px", "451px", "417px", "383px", "349px", "315px", "281px", "248px", "214px", "180px", "146px", "112px", "78px", "44px", "10px");
else
document.MM_Time[0][0].values[0] = new Array(485,451,417,383,349,315,281,248,214,180,146,112,78,44,10);
document.MM_Time[0][0].values[0].prop = "left";
if (ns5 || macIE5)
document.MM_Time[0][0].values[1] = new Array("178px", "169px", "159px", "150px", "141px", "131px", "122px", "113px", "103px", "94px", "84px", "75px", "66px", "56px", "47px");
else
document.MM_Time[0][0].values[1] = new Array(178,169,159,150,141,131,122,113,103,94,84,75,66,56,47);
document.MM_Time[0][0].values[1].prop = "top";
if (!ns4) {
document.MM_Time[0][0].values[0].prop2 = "style";
document.MM_Time[0][0].values[1].prop2 = "style";
}
document.MM_Time[0][1] = new String("sprite");
document.MM_Time[0][1].slot = 1;
if (ns4)
document.MM_Time[0][1].obj = document["Layer1"];
else if (ns5)
document.MM_Time[0][1].obj = document.getElementById("Layer1");
else
document.MM_Time[0][1].obj = document.all ? document.all["Layer1"] : null;
document.MM_Time[0][1].keyFrames = new Array(16, 30);
document.MM_Time[0][1].values = new Array(2);
if (ns5 || macIE5)
document.MM_Time[0][1].values[0] = new Array("551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px", "551px");
else
document.MM_Time[0][1].values[0] = new Array(551,551,551,551,551,551,551,551,551,551,551,551,551,551,551);
document.MM_Time[0][1].values[0].prop = "left";
if (ns5 || macIE5)
document.MM_Time[0][1].values[1] = new Array("207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px", "207px");
else
document.MM_Time[0][1].values[1] = new Array(207,207,207,207,207,207,207,207,207,207,207,207,207,207,207);
document.MM_Time[0][1].values[1].prop = "top";
if (!ns4) {
document.MM_Time[0][1].values[0].prop2 = "style";
document.MM_Time[0][1].values[1].prop2 = "style";
}
document.MM_Time[0][2] = new String("behavior");
document.MM_Time[0][2].frame = 31;
document.MM_Time[0][2].value = "MM_timelineGoto('Timeline1','1')";
document.MM_Time[0][3] = new String("sprite");
document.MM_Time[0][3].slot = 1;
if (ns4)
document.MM_Time[0][3].obj = document["Layer1"];
else if (ns5)
document.MM_Time[0][3].obj = document.getElementById("Layer1");
else
document.MM_Time[0][3].obj = document.all ? document.all["Layer1"] : null;
document.MM_Time[0][3].keyFrames = new Array(31, 45);
document.MM_Time[0][3].values = new Array(2);
if (ns5 || macIE5)
document.MM_Time[0][3].values[0] = new Array("504px", "474px", "444px", "415px", "385px", "355px", "325px", "296px", "266px", "236px", "206px", "176px", "147px", "117px", "87px");
else
document.MM_Time[0][3].values[0] = new Array(504,474,444,415,385,355,325,296,266,236,206,176,147,117,87);
document.MM_Time[0][3].values[0].prop = "left";
if (ns5 || macIE5)
document.MM_Time[0][3].values[1] = new Array("34px", "36px", "37px", "39px", "41px", "43px", "44px", "46px", "48px", "49px", "51px", "53px", "55px", "56px", "58px");
else
document.MM_Time[0][3].values[1] = new Array(34,36,37,39,41,43,44,46,48,49,51,53,55,56,58);
document.MM_Time[0][3].values[1].prop = "top";
if (!ns4) {
document.MM_Time[0][3].values[0].prop2 = "style";
document.MM_Time[0][3].values[1].prop2 = "style";
}
document.MM_Time[0][4] = new String("sprite");
document.MM_Time[0][4].slot = 1;
if (ns4)
document.MM_Time[0][4].obj = document["Layer1"];
else if (ns5)
document.MM_Time[0][4].obj = document.getElementById("Layer1");
else
document.MM_Time[0][4].obj = document.all ? document.all["Layer1"] : null;
document.MM_Time[0][4].keyFrames = new Array(46, 60);
document.MM_Time[0][4].values = new Array(2);
if (ns5 || macIE5)
document.MM_Time[0][4].values[0] = new Array("504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px", "504px");
else
document.MM_Time[0][4].values[0] = new Array(504,504,504,504,504,504,504,504,504,504,504,504,504,504,504);
document.MM_Time[0][4].values[0].prop = "left";
if (ns5 || macIE5)
document.MM_Time[0][4].values[1] = new Array("34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px", "34px");
else
document.MM_Time[0][4].values[1] = new Array(34,34,34,34,34,34,34,34,34,34,34,34,34,34,34);
document.MM_Time[0][4].values[1].prop = "top";
if (!ns4) {
document.MM_Time[0][4].values[0].prop2 = "style";
document.MM_Time[0][4].values[1].prop2 = "style";
}
document.MM_Time[0].lastFrame = 60;
for (i=0; i<document.MM_Time.length; i++) {
document.MM_Time[i].ID = null;
document.MM_Time[i].curFrame = 0;
document.MM_Time[i].delay = 1000/document.MM_Time[i].fps;
}
}
//-->
</script>
</head>
<body onLoad="MM_timelinePlay('Timeline1')">
<p><a href="http://www.baidu.com" onClick="return confirm('dfsdf');" onMouseOver="Status='baidu';" onMouseOut="Status='tt';return true;">open bai du</a></p>
<div id="Layer1" style="left: 485px; top: 178px;"><img src="../../图片/视觉/image011.jpg" width="115" height="100"></div>
<p> </p>
</body>
</html>