Js弹出窗口、居中、居角、扩大窗口至屏幕最大的代码

1.居中弹出窗口,并逐步扩大

linenum <scripttype="text/javascript"> //<![CDATA[ if(navigator.appName=="MicrosoftInternetExplorer"){ //最大化窗口 self.moveTo(-5,-5) self.resizeTo(screen.availWidth+8,screen.availHeight+8) //这个脚本定义的宽度其实比原窗口还要大那么一点. } varw=h=200; x=(screen.width-w)/2; y=(screen.height-h)/2; varn=open('','newWin','width='+w+',height='+h+',left='+x+',right='+x+',top='+y+',bottom='+y); n.document.write(' <script> document.write("temp");/*临时内容,去掉出错*/ document.body.innerHTML="";/*清空页面内容*/ document.οnclick=function()/*单击关闭窗口*/ </script>'); n.document.write('<h2>testmovingwindow</h2>'); n.focus(); vartimer=setInterval('fMovingWin()',1); functionfMovingWin(){ if(n.closed||(w>=screen.width+8&&h>=screen.height+8)){ clearInterval(timer); return; } try{ if(w<=screen.width+8)w+=2; if(h<=screen.height+8)h+=2; n.resizeTo(w,h) x=(screen.width-w)/2; y=(screen.height-h)/2; n.moveTo(x,y) }catch(e){}//shawl.qiuscript } //]]> </script>

2.居角弹出窗口,并逐步扩大

linenum <scripttype="text/javascript"> //<![CDATA[ if(navigator.appName=="MicrosoftInternetExplorer"){ //最大化窗口 self.moveTo(-5,-5) self.resizeTo(screen.availWidth+8,screen.availHeight+8) //这个脚本定义的宽度其实比原窗口还要大那么一点. } varw=h=200; x=y=-5; varn=open('','newWin','width='+w+',height='+h+',left='+x+',right='+x+',top='+y+',bottom='+y); n.document.write(' <script> document.write("temp");/*临时内容,去掉出错*/ document.body.innerHTML="";/*清空页面内容*/ document.οnclick=function()/*单击关闭窗口*/ </script>'); n.document.write('<h2>testmovingwindow</h2>'); n.focus(); vartimer=setInterval('fMovingWin()',1); functionfMovingWin(){ if(n.closed||(w>=screen.width+8&&h>=screen.height+8)){ clearInterval(timer); return; } try{ if(w<=screen.width+8)w+=2; if(h<=screen.height+8)h+=2; n.resizeTo(w,h) //从右下角逐步扩大窗口 /*x=screen.width-w y=screen.height-h n.moveTo(x,y)*/ //从左上角逐步扩大窗口 n.moveTo(x,y) }catch(e){}//shawl.qiuscript } //]]> </script>

3.附加:双击滚屏,单击停止,以Scrollbar的相对位置滚屏

linenum <scripttype="text/javascript"> //<![CDATA[ functionscb() document.οnmοusedοwn=function()catch(e){}} document.οndblclick=function() //]]>//shawl.qiuscript </script>

注意: 拷贝代码后需要 查找 " ", 并替换为 "". (不加引号)
原因: 优快云 的编码器在行末自动添加空格符" ", 而这段代码正好使用 js 的 在行末作为行链接, 因此行末就是空格, 而不是 , 需要手动转正.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值