我有以下代码,我试图在屏幕中央打开一个弹出窗口。这在 Firefox、Chrome 和 IE 中也可以正常工作,但在 Safari 中不起作用。我觉得 Safari 浏览器无法解释screen.width
和screen.height
属性。或者是别的什么?我会很感激任何帮助!提前致谢 :)
function openPopup(url){
var date = new Date(); //To uniquely identify a window, I'm appending this to the window name.
window.close(); //Closing the parent window.
var width=650, height=375;
var leftC =(screen.width / 2) - (width/ 2);
var topC =(screen.height / 2) - (height / 2);
window.open(url, "winName_"+date.getTime(), 'location=0, toolbar=no, scrollbars=0, resizable=no, width='+width+', height='+height+', top='+topC+', left='+leftC);
}