1.js
複製代碼代碼如下:
<script type="text/javascript">
function openwindow(url,name,iWidth,iHeight)
{
// url 轉向網頁的位址
// name 網頁名稱,可為空
// iWidth 彈出視窗的寬度
// iHeight 彈出視窗的高度
//window.screen.height獲得螢幕的高,window.screen.width獲得螢幕的寬
var iTop = (window.screen.height-30-iHeight)/2; //取得視窗的垂直位置;
var iLeft = (window.screen.width-10-iWidth)/2; //取得視窗的水平位置;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+' ,top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
</script>
2.呼叫方法
複製代碼代碼如下:
<a href="javascript:void(0);" onclick="javascript:openwindow('a.html','',400,200);">轉到a</a>