在 HTML 中调整浏览器窗口大小时执行脚本?
htmlweb developmentfront end technology更新于 2026/1/17 11:56:17
当 Web 浏览器窗口调整大小时,会触发 onresize 属性。
示例
您可以尝试运行以下代码来实现 onresize 属性 −
<!DOCTYPE html>
<html>
<body onresize = "display()">
<p>Resize the window to trigger event.</p>
<script>
function display() {
alert("Web browser window resized!");
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

