Home > object required > object required error in javascript internet explorer

Object Required Error In Javascript Internet Explorer

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 6.2 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 2231317 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 273k23126213 add a comment| up vote 0 down vote You're getting that error because inItemText isn't defined. Use document.getElementById('inItemText'). share|improve this answer a

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 6.2 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'; //error http://stackoverflow.com/questions/10576121/javascript-object-required-error-in-ie 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.2k15146170 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 209k37240372 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

this is your first visit, be sure to check out the FAQ by clicking the link above. You may have http://www.webdeveloper.com/forum/showthread.php?211464-Object-required-IE8-Compatibility to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: Object required - IE8 Compatibility Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… object required Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 06-18-2009,11:27 AM #1 BartvR View Profile View Forum Posts Registered User Join Date Jun 2009 Posts 1 Object required - IE8 Compatibility I've a problem with some javascript code since i upgraded to Internet Explorer 8. The error is: Object required This is object required error the function: HTML Code: function checkAfspraakRows() { var dropdown = document.getElementById("afspraak"); var selitem = dropdown.options[dropdown.selectedIndex].value; <-- the line where the error is generated (i think) if (selitem == "belafspraak") { showRow("datumBelAfspraakRow"); hideRow("datumHersteldRow"); } else if (selitem == "hervattingsafspraak") { hideRow("datumBelAfspraakRow"); showRow("datumHersteldRow"); setHersteldLabel("Hervatting"); } else if (selitem == "hersteldmelding") { hideRow("datumBelAfspraakRow"); showRow("datumHersteldRow"); setHersteldLabel("Hersteld"); } else { hideRow("datumBelAfspraakRow"); hideRow("datumHersteldRow"); } } function hideRow(rowID) { document.getElementById(rowID).style.display = "none"; } function showRow(rowID) { document.getElementById(rowID).style.display = "block"; } And here is the HTML code: Code:

 

© Copyright 2019|winbytes.org.