Internet Explorer 8 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 Internet Explorer 8 error, Object Required (JavaScript) up vote 0 down vote favorite I wrote a todo in chrome that works fine. I tested it in IE8 and it didn't work. So I made a new file to write specifically in IE8, and I can't even get a simple function to work properly. I would like help in finding out what i'm doing wrong. Thank you to anyone that can school me on this. HTML
Home
Javascript var inItemText = document.getElementById("inItemText"); function doIt() { var itemText; itemText = inItemText.value; document.getElementById("p1").innerHTML = itemText; form1.reset(); } javascript internet-explorer internet-explorer-8 share|improve this question asked Jan 30 '15 at 0:25 MrEhawk82 223317 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepted Make sure you do the inItemText assignment after the DOM has been loaded. Otherwise, document.getElementById("inItemText") won't find the element, because it doesn't exist yet. Either put it at the end of the , or use window.onload: var inItemText; window.onload = function() { inItemText = document.getElementById("inItemText"); }; share|improve this answer answered Jan 30 '15 at 0:36 Barmar 273k23126212 add a comment| up vote 0 down vote You're getting that error because inItemTehere 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 http://stackoverflow.com/questions/28227214/internet-explorer-8-error-object-required-javascript 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'; http://stackoverflow.com/questions/10576121/javascript-object-required-error-in-ie //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 err
be down. Please try the request again. Your cache administrator is webmaster. Generated Wed, 19 Oct 2016 02:10:33 GMT by s_wx1080 (squid/3.5.20)