Home >Web Front-end >HTML Tutorial >HTML implements page refresh when the window size changes (code)
The content of this article is about page refresh (code) when the window size changes in HTML. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"> <title>Document</title> <script> //窗口大小变化时候,进行刷新页面操作,防止样式混乱 var x=window.innerWidth; function resizeFresh(){ if(x!=window.innerWidth) location.reload(); } </script> </head> <body onresize="resizeFresh()"> <div style="min-width:800px; height: 400px; background-color: brown;"> </div> 刷新页面 </body> </html>
Related recommendations:
How to use js to implement the long press function in html (code)
html thead tag What is the function? Introduction to html thead tag attributes
The above is the detailed content of HTML implements page refresh when the window size changes (code). For more information, please follow other related articles on the PHP Chinese website!