Internet Explorer Javascript Error Object Required
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Javascript object required error in IE up vote 1 down vote favorite i'm creating mulitple planet objects in javascript to handle animation. The animation works fine for each planet but i am getting errors in IE 6/7 saying "object required on line 15 char 2" Code: var earthObj = null; var mercObj = null; var jupiObj = null; var animate; function init() { mercObj = document.getElementById('mercury'); earthObj = document.getElementById('earth'); jupiObj = document.getElementById('jupiter'); mercObj.style.position= 'relative'; mercObj.style.left = '54px'; mercObj.style.visibility = 'hidden'; earthObj.style.position= 'relative'; //error on this line earthObj.style.left = '80px'; earthObj.style.top = 300px'; } javascript object animation share|improve this question edited May 13 '12 at 23:50 VisioN 87.1k15146170 asked May 13 '12 at 23:48 user1281921 8629 3 Maybe you missing earth? –VisioN May 13 '12 at 23:50 Show us the markup, and where the script tag is. –Matt Ball May 13 '12 at 23:51 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote Before trying to call an object, test if it exists. earthObj = document.getElementById('earth'); if(!earthObj) { alert("Could not find Earth"); return; } share|improve this answer answered May 14 '12 at 0:08 Niet the Dark Absol 208k36240372 add a comment| up vote 0 down vote I am on mac and don't have any IE to try. Do you get the same error, if you change the code like this: function init() { var earthObj = null; var mercObj = null; var jupiObj = null; var animate; mercObj = document.getElementById('mercury'); earthObj = document.getElementById('earth'); jupiObj = document.getElementById('jupiter'); mercObj.style.position= 'relative'; mercObj.style.left = '54px'; mercObj.style.visibility = 'hidden'; !earhtObj && alert("There is no element with id 'earth'"); earthObj.style.left = '80px'; earthObj.style.top = '300px'; earthObj.style.position= 'relative'; } I came accros this post and thought if the error might be connected with IE6/7 bug that triggers when some global variable gets the same name as dom object. I also moved the earthObj.style.position= 'relat
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up JS Error http://stackoverflow.com/questions/10576121/javascript-object-required-error-in-ie in IE 8… “Object Required” up vote 0 down vote favorite 1 I am implementing pagination on a project currently in progress but I am getting an error with this piece of code in IE8: var rows = document.getElementById(tableName).rows; Here is the error: Message: Object required I am using this open source code for the pagination: http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/ Now my question would be, is this http://stackoverflow.com/questions/6385590/js-error-in-ie-8-object-required a valid piece of code for ie 8? if not what could I substitute to obtain the same results of the given piece of code? (or how can i fix this error :P) If more information is needed, I'll try my best to provide. javascript internet-explorer-8 share|improve this question asked Jun 17 '11 at 12:15 Dennis Martinez 2,46472947 Is your data coming from the database is in a small nos only ? –Nirmal Jun 17 '11 at 12:23 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted It looks like document.getElementById(tableName) is not finding the table which you're expecting, and so it returns null. null.rows is not valid, and so there's an error there. I'd recommend splitting that line into two and checking that the element is found before continuing: var table = document.getElementById(tableName), rows; if (table) { rows = table.rows; } else { alert("Couldn't find table with id: " + tableName); } share|improve this answer answered Jun 17 '11 at 12:19 nickf 286k146520629 Ah that is exactly what is going on, the table is being created dynamically using jquery,
be down. Please try the request again. Your cache administrator is webmaster. Generated Wed, 19 Oct 2016 04:31:30 GMT by s_wx1011 (squid/3.5.20)