[英]Javascript object required (IE8)
javascript for elements re-size works fine on my tumblr theme, but I get the object required error on the following line in IE8: 重新调整大小的元素的javascript在我的tumblr主题上可以正常使用,但是在IE8的以下行上出现对象必需的错误:
fschildren = $("fs_wrapper").childNodes;
Thanks for help Peter 谢谢彼得的帮助
<script type="text/javascript">
function resizedivs() {
$ = function(id) { return document.getElementById(id); }
fschildren = $("fs_wrapper").childNodes;
postc = 0;
thedivs = new Array();
for(i = 0; i < fschildren.length; i++) {
if(fschildren[i].tagName == "DIV") {
thedivs[postc] = fschildren[i];
postc++;
}
}
newwidth = 0;
for(i = 0; i < thedivs.length; i++) {
if(newwidth <= document.body.clientWidth) {
newwidth = newwidth + (thedivs[i].clientWidth)+15;
}
if(newwidth >= document.body.clientWidth || newwidth >= 1300) { // 100 for padding minus 15 extra
newwidth = newwidth - (thedivs[i].clientWidth+15);
break;
}
}
$("fs_wrapper").style.width = newwidth-0+"px";
$("fs_wrapper").style.position = "relative";
$("fs_wrapper").style.left = "0px";
$("sec2").style.width = newwidth-0+"px";
$("sec2").style.position = "relative";
$("sec2").style.left = "0px";
$("sec3").style.width = newwidth-0+"px";
$("sec3").style.position = "relative";
$("sec3").style.left = "0px";
}
window.onresize = function() {
resizedivs();
}
window.onload = function() {
resizedivs();
}
</script>
Does object really exist? 对象真的存在吗?
myObj = document.getElementById('myObj');
if(!myObj) {
alert("4004 not found");
return;
}
You are missing the right selector .
您缺少正确的选择器.
for class or #
for id 类或#
中的id
see this http://www.w3schools.com/jquery/jquery_ref_selectors.asp 看到这个http://www.w3schools.com/jquery/jquery_ref_selectors.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.