最后二十分,实现窗口上到处乱飞的一个广告,这个广告碰到屏幕要发出声音.
最后的二十分.请各位大侠拔剑相助.
------解决方案--------------------var speed=2;
var isie=0;
if(window.navigator.appName== "Microsoft Internet Explorer "&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf( "MSIE ")+5,window.navigator.appVersion.indexOf( "MSIE ")+8)> =5.5){
isie=1;
} else {
isie=0;
}
if(isie){
var preloadit=new Image();
preloadit.src=imagepath;
}
function pop() {
if(isie) {
x=x+dx;y=y+dy;
oPopup.show(x, y, imagewidth, imageheight);
if(x+imagewidth+5> screen.width) dx=-dx;
if(y+imageheight+5> screen.height) dy=-dy;
if(x <0) dx=-dx;
if(y <0) dy=-dy;
startani=setTimeout( "pop(); ",40);
}
}
function dismisspopup(){
clearTimeout(startani);
oPopup.hide();
}
function dowhat(){
try{
top.frame_right.right.location.href=imageclick;
}catch(x){
window.open(imageclick);
}
dismisspopup();
}
if(isie) {
var x=0,y=0,dx=speed,dy=speed;
var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body;
oPopupBody.innerHTML = ' <input type=image width= '+imagewidth+ ' height= '+imageheight+ ' src= " '+preloadit.src+ ' " hidefocus= "true "> ';
oPopupBody.onclick=dowhat;
}
function goFly(){
setTimeout( "pop(); ", (Math.round(Math.random() * 2000) + 3000));
}
保存为一个js 文件move2.js
<script>
var imagepath= "/img/surprise3.gif ";
var imagewidth=16;
var imageheight=16;
var imageclick= "/tools.aspx ";
</script>
<SCRIPT language=javascript src= "move2.js "> </SCRIPT>
<script>
goFly();
</script>
保存一个index.html文件
------解决方案--------------------乱? 是像文字屏保那样? 还是像分子热运动那样?
无非就是控制div的位置而已,再判断一下clientWidth,clientHeight,过了就变向并控制mediaplyaer播放个音乐啥的