js 如何获取窗体大小变化 的 事件?在线等 html页面中,现需,窗口变小时,弹出 a, 窗口变大时,弹出b, 这如何实现呀,thanks 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 onresize事件window.onresize = function(){ alert(1)} window.onresize = function(){ if (document.documentElement.clientWidth < originalWidth || document.documentElement.clientHeight < originalHeight){ alert('a');} else{ alert('b'); }} 4楼的代码运行不了。望再调试下。thanks 4楼他省略了originalWidth 的赋值,改下就好啦var originalWidth = document.documentElement.clientWidth, originalHeight = document.documentElement.clientHeight;window.onresize = function(){ var _originalWidth = document.documentElement.clientWidth; _originalHeight = document.documentElement.clientHeight if (_originalWidth < originalWidth || _originalHeight < originalHeight){ alert('a');} else{ alert('b'); } originalWidth = _originalWidth; originalHeight = _originalHeight;} window.onscroll = function () { sc(); }; window.onresize = function () { sc(); }; window.onload = function () { sc(); };function sc() { var h = document.documentElement.clientHeight - 80; $("#result").css({ height: h }); $("#result").css("overflow-y", "scroll"); $("#result").css("overflow-x", "scroll");}一个例子 6楼的代码也有问题,当窗口变小时,会弹出a 也会弹出b,当窗口变大时,弹出二回b,望再调试下。。 ie8 window.open报未指明的错误 正则表达式求解 怎么获取复选框下面的值 100分求救获取另存为的路径! 下拉框默认显示当前的时间! 关于Form中action的写法 关于弹出窗口的问题(高手进来) 我怎么能让我的FUNCTION只在需要时才执行呢??? 哪位大虾给段代码,或者,推荐一个网址也行,先谢过了 .NET开发中,用JS实现点击按钮改变页面上所有TextBox中文字的颜色 window.showModalDialog 对像不支持此属性或方法 求js解密、规范工具,能将下面代码还原的!发我有邮箱[email protected]
alert(1)
}
window.onresize = function(){
if (document.documentElement.clientWidth < originalWidth || document.documentElement.clientHeight < originalHeight){
alert('a');
}
else{
alert('b');
}
}
var originalWidth = document.documentElement.clientWidth,
originalHeight = document.documentElement.clientHeight;
window.onresize = function(){
var _originalWidth = document.documentElement.clientWidth;
_originalHeight = document.documentElement.clientHeight
if (_originalWidth < originalWidth || _originalHeight < originalHeight){
alert('a');
}
else{
alert('b');
}
originalWidth = _originalWidth;
originalHeight = _originalHeight;
}
window.onresize = function () { sc(); };
window.onload = function () { sc(); };
function sc() {
var h = document.documentElement.clientHeight - 80;
$("#result").css({ height: h });
$("#result").css("overflow-y", "scroll");
$("#result").css("overflow-x", "scroll");
}
一个例子
当窗口变大时,弹出二回b,
望再调试下。。