views:

28

answers:

4

i want to initiate a function when user finishes resizing of his browser window. please suggest how to do in either pure JS or jquery.

Note: i want to raise the event only once and after user has done browser resizing.

A: 
window.onresize = function() { alert('hi'); };
zincorp
this will constantly call this function, i want tgis function to be called only once and when user has done with his resizin
Praveen Prasad
A: 

Check here.

Ekin Koc
A: 

From the docs:

$(window).resize(function() {
   $('#log').append('<div>Handler for .resize() called.</div>');
});
RKitson
its clearly written that this fn will be constantly called , i want it to be called after resizing is done
Praveen Prasad
+1  A: 

You can introduce a small delay before running the resize handler using setTimeout and keep renewing this timeout until the events stop. This article explains how to do it - http://ajaxian.com/archives/delaying-javascript-execution

Chetan Sastry
i myself was doing same thing but iwas looking some better solution
Praveen Prasad
You can use some of the plugins out there (see the comments in the article) but they all essentially do the same thing.
Chetan Sastry
Or ditch Internet Explorer ;)
Chetan Sastry