Javascript set browser window size

痴心易碎 提交于 2019-11-27 02:12:35

问题


What is the best way to set the size of the browser window when the page loads? I think this can be done in JavaScript. Please explain. Here is my code that is not working!

<html>
<body onload="window.resizeTo(640,480)">
<video src="rushmore.mp4" controls="controls">
your browser does not support the video tag
</video>
</body>
</html>

回答1:


I put this in an answer as the comment became to long.

The only thing that I have found that is close to the resizing of the chrome window is to use a chrome extension that can resize the window. The actual extension command is chrome.windows.update(...).

Take a look here.

But I am not sure this is what you are looking for.
If it still interests you there are at least 2 extensions that can do this, that I have seen try this one

Be happy and good luck!




回答2:


This should do the trick, setting the height and width to your desired dimensions.

window.resizeTo(500,500)

You could set it onload.

<body onload="window.resizeTo(500,500)">


来源:https://stackoverflow.com/questions/5238603/javascript-set-browser-window-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!