天天看點

無邊網頁視窗的制作

首先要做一個索引頁,也就是你要首先打開的頁面,比如 index.htm

  這個頁面裡不需要任何的内容,他的作用就是制造一個無框頁面然後把它滑入頁面,然後關閉自己的這個索引頁,隻要在這個頁面的<body>裡加入如下代碼:

<!-- HHCtrl Object -->

<object id="CloseWindow" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">

<param name="Command" value="Close">

</object>

<script>

var w=640,h=420;

var xpos=0,ypos=0,targetx=(screen.width-w)/2,targety=(screen.height-h)/2;

function go()

{

if (targetx-xpos>1)

{ xpos=(targetx+9*xpos)/10;

popup.moveTo(xpos,targety); }

else

{ clearTimeout(mm);

this.focus();

CloseWindow.Click(); }

mm=setTimeout("go()",10);

}

self.moveTo(-2222,-2222);

var appName=navigator.appName;

//判斷不是Netscape,Opera或Tencent Explorer

if (appName.indexOf('Microsoft')!=-1 && document.body.clientTop==2 && window.external.x!='Wibble')

var popup=window.open('winmove.htm','','fullscreen=1');

popup.moveTo(-1800,targety);

popup.resizeTo(w,h);

setTimeout("go()",500);

{ alert("請使用IE5.0或其以上版本浏覽,謝謝!"); }

</script>

  講到這裡,滑入的效果就OK了,現在講滑出,開始我以為在關閉視窗的**圖檔裡定義javascript:close()就可以關閉滑出了,可是發現隻能關閉,但是不是滑出關閉,後來才知道這需要一個script才行

  代碼如下,把這個代碼加入到引用頁裡,也就是這個示例的winmove.htm這裡頁裡:

var xstep=0,targetx=(screen.width-w)/2,targety=(screen.height-h)/2;

function exit()

if(xstep+targetx<screen.width)

{ xstep=0.1+xstep*2;

window.moveTo(targetx+xstep,targety); }

{ clearTimeout(mo);

window.close(); }

mo=setTimeout("exit()",10);

  然後在關閉視窗的**圖檔上這樣做:

<img src="http://www.45it.com/htmldata/2005-12-12/close_d.gif" alt="close window" style="cursor:hand" width="11" height="11">

  最小化圖檔連結代碼

<img src="http://www.45it.com/htmldata/2005-12-12/p_w_picpaths/min.gif" border="0" alt="min window" style="cursor:hand" width="11" height="11">

  最小化的script

<object id="HHCtrl" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">

<param name="Command" value="Minimize">

<!--

function min(){

this.focus();HHCtrl.Click(); }

-->

  最後要說的一點是winmove這個頁面要定義一下css,把頁面的滾動條定義為無,否則無框頁面會存在一個滾動條的

<style type="text/css">

body { overflow:hidden }

</style>

繼續閱讀