jQuery: The Write Less, Do More JavaScript Library

$(window).bind('resize', fn) not working in IE

View: New views
5 Messages — Rating Filter:   Alert me  

$(window).bind('resize', fn) not working in IE

by sam-166 :: Rate this Message:

| View Threaded | Show Only this Message


Can anyone verify that $(window).bind('resize', fn) doesn't work in
IE?  $(window).bind('scroll', fn) works fine for me, but not resize.

I'm using 1.2.6.

Thanks.

Re: $(window).bind('resize', fn) not working in IE

by Kean-2 :: Rate this Message:

| View Threaded | Show Only this Message


try

$(window).resize(fn);

On Jan 13, 3:54 pm, sam <sam.from.hackern...@...> wrote:
> Can anyone verify that $(window).bind('resize', fn) doesn't work in
> IE?  $(window).bind('scroll', fn) works fine for me, but not resize.
>
> I'm using 1.2.6.
>
> Thanks.

Re: $(window).bind('resize', fn) not working in IE

by dave.methvin :: Rate this Message:

| View Threaded | Show Only this Message


Do you have a simple test case? Resize works for me in IE.

Re: $(window).bind('resize', fn) not working in IE

by sam-166 :: Rate this Message:

| View Threaded | Show Only this Message


TI'm injecting jQuery into any webpage (via a bookmarklet).  This
works fine, but for some strange reason $(window).bind("resize")
doesn't work with IE.  No errors, just doesn't fire the event.

To see this, execute this code while on any webpage (using Firebug
Javascript Console):

//load jQuery
var js = document.createElement('script');
js.type = "text/javascript";
js.src = "http://localhost/js/jquery-1.3.js";
document.body.appendChild(js);

//this is strange:  $ is undefined until a setTimeout.
//even stranger: setTimeout must be at least 50 (for me)
setTimeout(function(){

       //change all link colors to random.
        var r = function(){
                var hex = Math.floor(Math.random()*255*255*255).toString(16);
                while (hex.length<6) hex = "0" + hex;
                hex = "#" + hex;
                $("a").css("color", hex);
        };

        //bind it.  resize wont work in IE.
        $(window).bind("resize", r);
        $(window).bind("scroll", r);
        r();
}, 50);



On Jan 13, 9:32 pm, Dave Methvin <dave.meth...@...> wrote:
> Do you have a simple test case? Resize works for me in IE.

Re: $(window).bind('resize', fn) not working in IE

by sam-166 :: Rate this Message:

| View Threaded | Show Only this Message


I believe I found the bug.

Seems like that if you set window.onresize in IE before the document
is completely loaded, it won't work.

Whatever.