用window.createpopup()成功實(shí)現(xiàn)了在桌面顯示一個(gè)無(wú)窗口的flash.
將下面的代碼,保存為qq.hta,雙擊運(yùn)行即可。關(guān)閉方法,任務(wù)管理器中關(guān)閉mshta.exe即可。
代碼如下:
<hta:application id=ohta
applicationname=myapp
border=none
caption=no
icon=filename.ico
maximizebutton=no
minimizebutton=no
showintaskbar=no
ingleinstance=no
sysmenu=no
version=1.0
windowstate=minimize
/>
<script language=javascript type=text/javascript>
function mm_reloadpage(init) { //reloads the window if nav4 resized
if (init==true) with (navigator) {if ((appname==netscape)&&(parseint(appversion)==4)) {
document.mm_pgw=innerwidth; document.mm_pgh=innerheight; onresize=mm_reloadpage; }}
else if (innerwidth!=document.mm_pgw || innerheight!=document.mm_pgh) location.reload();
}
mm_reloadpage(true);
var imagewidth=200 //這兩行寫彈出窗口的大小
var imageheight=200
var speed=3;
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;
}
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();,50);
}
}
if(isie) {
var str='<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width=200 height=200><param name=movie value=http://files.jb51.net/demoimg/200912/qqpet.swf /><param name=quality value=high /><param name=wmode value=transparent /><param name=bgcolor value=#ffffff><embed src=http://files.jb51.net/demoimg/200912/qqpet.swf wmode=transparent quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width=300 height=190></embed></object>';
var x=0,y=0,dx=speed,dy=speed;
var opopup = window.createpopup();
var opopupbody = opopup.document.body;
//opopup.document.bgcolor=orange; //桔黃色背景顏色
opopup.document.bgcolor=#ffffff; //白色背景
opopupbody.innerhtml = str;
pop();
}
</script>