| 几种不错的新开窗口方式 |
| 作者/IDCity 时间/2007-5-9 19:37:00 类别/日志 查看/ |
| 标签:代码 |
|
1.新开窗口,指定大小,自动屏幕居中 请在<head></head>之间输入下面的代码 <script language="javascript"> var win = null; function NewWindow(mypage,myname,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' win = window.open(mypage,myname,settings) } </script> 2.新开无边框窗口,指定大小,自动屏幕居中 请在<head></head>之间输入下面的代码 <script language="javascript"> function movetocenter(w,h){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; zz=window.open('red.htm','','fullscreen'); zz.resizeTo(w,h); zz.moveTo(LeftPosition,TopPosition); } </script> 3.新开全屏窗口 请在<head></head>之间输入下面的代码 <script> <!-- function fullwin(targeturl){ window.open(targeturl,"","fullscreen,scrollbars") } //--> </script> 4.调用方法 1.<a href="red.htm" onclick="NewWindow(this.href,'opwd','400','300','no','center'); return false" onfocus="this.blur()">新开窗口,指定大小,自动屏幕居中</a> 2.<a href="#" onclick="movetocenter(400,400)">新开无边框窗口,指定大小</a> 3.<a href="#" onClick="fullwin('red.htm')">新开全屏窗口</a> 效果 ![]() 已经完成的HTML页面代码,复制即可。 <html><head><title>东莞城市电信IDC</title><META content="text/html; charset=gb2312" http-equiv=Content-Type><META http-equiv="keywords" content="windows,windows me,windows2000,windows 9x,windows NT,linux,电脑文摘,小说下载,操作系统,软件教程,编程心得,网页特效";charset=gb2312><script language="javascript"> var win = null; function NewWindow(mypage,myname,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' win = window.open(mypage,myname,settings) } </script><script language="javascript"> function movetocenter(w,h){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; zz=window.open('red.html','','fullscreen'); zz.resizeTo(w,h); zz.moveTo(LeftPosition,TopPosition); } </script><script> <!-- function fullwin(targeturl){ window.open(targeturl,"","fullscreen,scrollbars") } //--> </script></head><body><P><a href="red.html" onclick="NewWindow(this.href,'opwd','400','300','no','center');return false" onfocus="this.blur()">新开窗口,指定大小,自动屏幕居中</a><br><br><a href="#" onclick="movetocenter(400,400)">新开无边框窗口,指定大小</a><br><br><a href="#" onClick="fullwin('red.html')">新开全屏窗口</a></P></body></html> |
| 查看该用户更多文章>> |
