新彈出窗口的幾種方法

新彈出窗口的幾種方法

一、新開窗口,指定大小,自動屏幕居中
首先請在<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>
二、新開無邊框窗口,指定大小自動屏幕居中
然後在<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>
三、新開全屏窗口
請繼續在<head></head>之間粘貼右邊的代碼;
<script>
<!--
function fullwin(targeturl){
window.open(targeturl,"","fullscreen,scrollbars")
}
//-->
</script>

附加說明:
調用方法:
1.<a href="red.htm" οnclick="NewWindow(this.href,'opwd','400','300','no','center');return false" οnfοcus="this.blur()">新開窗口,指定大小,自動屏幕居中</a>

2.<a href="#" οnclick="movetocenter(400,400)">新開無邊框窗口,指定大小</a>

3.<a href="#" onClick="fullwin('red.htm')">新開全屏窗口</a>
發佈了66 篇原創文章 · 獲贊 0 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章