views:

62

answers:

2

Hi all:

Is there a way to find out the id of the IE window that generates alert boxes? I assume it is the document or window itself.

Either simple html or jQuery can be used.

I tried something like:

var id = $(this).parent().attr('id');

but to no avail.

Ultimately I want to find out the ID of the window/document which generates javascript alerts so I can override it.

Thanks.

A: 

Not sure why you would need to do this but if you mean that you want to override the alert function it's pretty easy:

alert = function() {
    // do some custom stuff here
};
Jared
+2  A: 

If the document did not specified an ID attribute for the body, there's not much info you can gather... the html tag doesn't specify an ID attribute either...

You must build a mechanism yourself to identify your windows..

See the jQuery data() to attach a custom "property" to a DOM object if you want to keep your windows handles somewhere.

To override the alert function, see my response to this question: http://stackoverflow.com/questions/1729501/javascript-overriding-alert/1729684#1729684

Good luck

Mike Gleason jr Couturier