/** *Created by PanJiaChen on 16/11/29. * @param {Sting} url 子窗口需要打开的页面url * @param {Sting} strWindowName 子窗口名称 * @param {Sting} title 页面标题 */ export default function openWindow(url, strWindowName, title, w, h) { // Fixes dual-screen position Most browsers Firefox // const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left // const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top // const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width // const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height const width = w || screen.availWidth - 40 const height = h || screen.availHeight - 50 const left = (screen.availWidth - width) / 2 const top = (screen.availHeight - height) / 2 console.log(width, height) const newWindow = window.open( url, strWindowName, // title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left ) // Puts focus on the newWindow if (window.focus) { newWindow.focus() } console.log(url) // 修改窗口标题 newWindow.onload = function() { newWindow.document.title = title } console.log() }