IE中, 如果未给一个元素给定宽度(或者其它值), 在取值时是取不到的.
象下面两个funciton, 如果不判断, 在ie中很可能就出错了.
function changeWidth(id, changeValue) {
if (document.getElementById(id) && document.getElementById(id).style.width != "")
document.getElementById(id).style.width = (parseInt(document.getElementById(id).style.width) + changeValue) + "px";
}
function changeLeft(id, changeValue) {
if (document.getElementById(id) && document.getElementById(id).style.left != "")
document.getElementById(id).style.left = (parseInt(document.getElementById(id).style.left) + changeValue) + "px";
}
本文介绍在Internet Explorer浏览器中,如何安全地调整HTML元素的宽度和左偏移量。通过检查元素是否已设置初始宽度或位置来避免脚本错误。
2364

被折叠的 条评论
为什么被折叠?



