Home > Article > Web Front-end > Fixed form size_html/css_WEB-ITnose
Problem:
When I open a form, I drag the form border with the mouse to change its size. When the form size is reduced to a certain value, the form size is fixed and cannot be reduced any further.
Please ask:
How to implement it with js?
<!DOCTYPE HTML><html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <div id="a"></div> <div id="b"></div> <script> var $ = function(id){ return document.getElementById(id); }; window.onresize = function(){ $('a').innerHTML = document.documentElement.clientWidth $('b').innerHTML = document.documentElement.clientHeight var minWidth = 900; var minHeight = 500; if( document.documentElement.clientWidth < minWidth && document.documentElement.clientHeight < minHeight ){ window.resizeTo(minWidth, minHeight); } } </script> </body></html>
Answer from the 1st floor, I tried it, but it doesn’t work. My browser is IE9. Is it a browser problem?
resizeTo only works on pop-up windows
This requirement cannot be met.
You can only ask the body or div to open the page so that scroll bars appear, so that the layout of the page does not change.
window.onresize = function(){ $('a').innerHTML = document.documentElement.clientWidth $('b').innerHTML = document.documentElement.clientHeight var minWidth = 900; var minHeight = 500; if( document.documentElement.clientWidth < minWidth && document.documentElement.clientHeight < minHeight ){ document.body.style.width = minWidth + 'px'; document.body.style.height = minHeight + 'px'; }}