1. 居中弹出窗口, 并逐步扩大
- linenum
- <script type="text/javascript">
- //<![CDATA[
- if (navigator.appName=="Microsoft Internet Explorer") {
- //最大化窗口
- self.moveTo(-5,-5)
- self.resizeTo(screen.availWidth +8,screen.availHeight+8)
- //这个脚本定义的宽度其实比原窗口还要大那么一点.
- }
- var w=h=200;
- x=(screen.width-w)/2;
- y=(screen.height-h)/2;
- var n=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>test moving window</h2>');
- n.focus();
- var timer=setInterval('fMovingWin()',1);
- function fMovingWin(){
- 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.qiu script
- }
- //]]>
- </script>
2. 居角弹出窗口, 并逐步扩大
- linenum
- <script type="text/javascript">
- //<![CDATA[
- if (navigator.appName=="Microsoft Internet Explorer") {
- //最大化窗口
- self.moveTo(-5,-5)
- self.resizeTo(screen.availWidth +8,screen.availHeight+8)
- //这个脚本定义的宽度其实比原窗口还要大那么一点.
- }
- var w=h=200;
- x=y=-5;
- var n=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>test moving window</h2>');
- n.focus();
- var timer=setInterval('fMovingWin()',1);
- function fMovingWin(){
- 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.qiu script
- }
- //]]>
- </script>
3. 附加: 双击滚屏, 单击停止, 以 Scroll bar 的相对位置滚屏
- linenum
- <script type="text/javascript">
- //<![CDATA[
- function scb()
- document.οnmοusedοwn=function() catch(e){} }
- document.οndblclick=function()
- //]]> //shawl.qiu script
- </script>
注意: 拷贝代码后需要 查找 " ", 并替换为 "". (不加引号)
原因: CSDN 的编码器在行末自动添加空格符" ", 而这段代码正好使用 js 的 在行末作为行链接, 因此行末就是空格, 而不是 , 需要手动转正.