2010-10-25 207 views
0
function open1(){ window.open('http://www.pageresource.com/jscript/jex5.htm','ddsfa','width=400,height=200 「); }

你好顯示彈出中心的新窗口

我想表明這個彈出來中心點擊時的「你好」

回答

1

要在你需要使用的寬度和屏幕的高度中心打開。一個在點擊打開剛纔綁定它的window.onload:

 function open1() { 

      var left = (screen.width - 400)/2, 
       top = (screen.height - 200)/2, 
       settings = 'height=200,width=400,top=' + top + ',left=' + left; 

      window.open('http://www.pageresource.com/jscript/jex5.htm','popUp',settings); 
     } 

     window.onload = function(){ 
      document.getElementById("openPopup").onclick = open1; 
     } 
0

ID爲「開放式」創建HTML元素和嵌入這個腳本插入到文檔的頭:

function open1() { 

    var w = 400, // width of your block 
     h = 200, // height of your block 
     l = (screen.width - w)/2, // block left position 
     t = (screen.height -h)/2; //block top position 

    window.open('http://www.pageresource.com/jscript/jex5.htm','','height=' + h + ',width=' + w + ',top=' + t + ',left=' + l); 
} 

window.onload = function() { 
     document.getElementByID("open").onclick = open1; 
}