简体   繁体   English

javascript和jQuery调整大小事件在IE Internet Explorer中不起作用

[英]Javascript and jquery resize event not working in IE Internet Explorer

I don't know what i am doing wrong but my onresize works fine in firefox but is not working in IE. 我不知道我在做什么错,但是我的onresize在firefox中可以正常工作,但在IE中不起作用。

$(window).bind('resize', function () {resize1()}); 
window.onresize= function(){resize1()};
body.onresize= function(){resize1()};
$(window).resize(function(){resize1()});

I have tried all four of these and all works fine in ff but none of them work in IE. 我已经尝试了所有这四个方法,并且在ff中都可以正常工作,但是在IE中都没有。 What am i doing wrong. 我究竟做错了什么。

My resize1 function looks like this: 我的resize1函数如下所示:

function resize1(){
var w = $(window).height();
var h = $('.header').height();
var ht = (w-h);
document.getElementById('div').style.height=ht +"px";

}

My ultimate goal is to have the div resize when someone resizes the window by dragging a corner. 我的最终目标是当有人通过拖动角来调整窗口大小时使div大小改变。 Again works fine in FF but not working in IE. 再次在FF中工作正常,但在IE中不工作。 Thanks for your help. 谢谢你的帮助。

When i call the function using "onload" it works fine it just doesn't fire when using the onresize event. 当我使用“ onload”调用该函数时,它工作正常,但在使用onresize事件时不会触发。 So when i load the page the div is the correct size but then when i resize it doesn't fire the function again. 因此,当我加载页面时,div是正确的大小,但是当我调整大小时,它不会再次触发该功能。 So it seems to be something with the event oneresize not being recognized by IE. 因此,似乎oneresize事件未被IE识别。 ?? ??

$(window).resize(function(){resize1()});

function resize1(){

var w = $(window).height();
var h = $('.header').height();
var ht = w-h;

$('#div').height(ht);

}

Which version of IE? 哪个版本的IE? 8.0 and earlier get values without px Try document.getElementById('div').style.height=ht; 8.0和更早版本获取没有px值尝试document.getElementById('div').style.height=ht;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM