Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

javascript - JavaScript窗口调整大小事件(JavaScript window resize event)

How can I hook into a browser window resize event?

(如何挂钩浏览器窗口调整大小事件?)

There's a jQuery way of listening for resize events but I would prefer not to bring it into my project for just this one requirement.

(有一种侦听调整大小事件的jQuery方式,但我不希望仅出于这一要求就将其引入我的项目中。)

  ask by Dead account translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

jQuery is just wrapping the standard resize DOM event, eg.

(jQuery只是包装了标准的resize DOM事件,例如。)

window.onresize = function(event) {
    ...
};

jQuery may do some work to ensure that the resize event gets fired consistently in all browsers, but I'm not sure if any of the browsers differ, but I'd encourage you to test in Firefox, Safari, and IE.

(jQuery 可以做一些工作来确保在所有浏览器中一致地触发resize事件,但是我不确定任何浏览器是否有所不同,但是我鼓励您在Firefox,Safari和IE中进行测试。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...