I would like to limit the window width to less than 500px in JavaScript, but is such an API provided?
I looked it up and found something called window.minWidth, but it didn't work well.
It works with chrome.
Thank you for your cooperation.
https://stackoverflow.com/questions/10610899/disable-browser-window-resize
https://stackoverflow.com/questions/22418306/css-or-javascript-option-to-limit-sizing-browser-window-size
The English version of this document will be used as a reference.
$(window).resize(function(){
window.resizeTo (1024,800);
});
window.onresize=function(){
if(window.innerWidth<900||window.innerHeight<600){
window.resizeTo (1024,800);
}
};
You can't limit it, so you hack a resize event.
Personally speaking,
We do not recommend limiting or fixing the browser window size.
If you want to fix it, you just need to fix the width and height of the contents (body, container, etc.).
Basically, the width of the window can be changed freely by the client.
You may move a little or limit the "broad display" or "snap" capabilities of the operating system.
It's also a trick used on so-called annoying advertising sites.View your browser at maximum without permission
It's a way to limit the browser's movement and display it more than advertising, so there might be some countermeasures on the browser side.
I don't know what specifications and applications are, but if it's a website, I think it's better to aim to be able to display any window width.
If you really want to use a fixed window, I think you should use so-called pop-up and modal display using Javascript instead of a new browser window.
© 2024 OneMinuteCode. All rights reserved.