我有在啓動與window.open可調整大小= 1一個新的窗口,在我的js文件SCORM模塊:如何獲得高度和寬度窗口後調整
function OpenScormModuleWindow(scormModuleId, scormModuleUrl, title, width, height)
{
_scormModuleId = scormModuleId;
InitializeUserScormModule();
scormModuleWindow = window.open(scormModuleUrl, "title", "width=" + width + ", height=" + height + ", resizable = 1");
scormModuleWindow.focus();
}
在我看來
我有:
var myWidth = 0, myHeight = 0;
if (typeof (window.innerWidth) == 'number')
{
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
{
myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
}
else if (document.body && (document.body.clientWidth || document.body.clientHeight))
{
myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
}
我得到的高度和寬度,但不正確
用戶現在可以調整大小,當窗口的大小正確,我怎麼能得到高度和寬度好嗎?
我需要獲取這些值,以便我可以保存它,下次打開窗口時它是正確的大小。
感謝
您是否需要調用匿名函數來調用setWindowSize?你能不能寫「window.addEventListener('resize',setWindowSize);」 ? – chris5marsh
@ chris5marsh絕對正確! –