I want to bind a function to the `beforeunload` event of a child window in Javascript.
I have the following code:

```
newWind = window.open(settings.url, "Dialog", "width=" + settings.width + ",height=" + settings.height + ",resizable=" + settings.resizable + ",scrollbars=" + true);

newWind.onunload = function() { alert('test'); }

```

Works fine in Firefox, but fails in IE7. Can anyone see what I am doing wrong?