Since you are trying to call this function on the resize of the window, you will want to bind the function to the window and not to the document. To support versions of IE that are less than 9, you will want to use
attachEvent. Please note that
attachEvent requires you to specify the
on keyword. Here is an example:
P.s.: If you want to exact answer you should give more information about your browser and version.
Similarly, you can remove events in the same way
window.location.href = window.location.pathname + window.location.search + window.location.hash; // creates a history entry
window.location.replace(window.location.pathname + window.location.search + window.location.hash); // does not create a history entry
window.location.reload(false); // If we needed to pull the document from // the web-server again (such as where the document contents // change dynamically) we would pass the argument as 'true'.