Document.getelementbyid Innerhtml Runtime Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Unknown Runtime Error In Javascript Innerhtml In Ie
and policies of this site About Us Learn more about Stack Overflow how to fix unknown runtime error the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags script601: unknown runtime error 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
Unknown Runtime Error Ie8
takes a minute: Sign up InnerHTML issue in IE8 and below up vote 3 down vote favorite 1 I am editing some code from a previous developer for a timetable filtering system. The way I would tackle this myself is using jQuery so I am having a few issues debugging this problem. There seems to be an issue with the
Innerhtml Ie8
Javascript in IE. Here is the code where the issue is arising: The Javascript: if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("showtimetable").innerHTML=xmlhttp.responseText; jQuery('div #moreInfo a').each(function() { var $link = jQuery(this); var $dialog = jQuery('
Venue | Session | Age | Activity */ ?> | Time | Info | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
pagination->getListFooter(); ?> | ||||||||||||
centreDescription!=''){echo ''.$item->centre.'';} else {echo $item->centre;}?> | class;?> | ageRange;?> | gn;?> | weekda here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies ie11 innerhtml not working of this site About Us Learn more about Stack Overflow the company Innerhtml Not Working In IeBusiness Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users cannot set property 'innerhtml' of null 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 http://stackoverflow.com/questions/13817999/innerhtml-issue-in-ie8-and-below minute: Sign up targetElem.innerHTML Unknown Runtime Error in IE8 up vote 0 down vote favorite I'm receiving an "Unknown Runtime Error" in IE8 on Windows 7 VM. Here is my jsFiddle The error says: unknown runtime error. DmiAjax.js, line 317, character 9 Also, to help visualize, here's screenshot of said error: The error occurs when I click my "Get Quotes" button, which http://stackoverflow.com/questions/18594244/targetelem-innerhtml-unknown-runtime-error-in-ie8 looks like this: javascript jquery html css internet-explorer-8 share|improve this question edited Sep 3 '13 at 14:02 Mr_Green 18.5k2186153 asked Sep 3 '13 at 13:58 user2712343 613 2 There is no need to use javascript:. Get rid of it. better yet, do it unobtrusively. –epascarello Sep 3 '13 at 14:00 Your fiddle has a lot of errors in the console. You should not have a script tag in the JavaScript section. –epascarello Sep 3 '13 at 14:02 Don't know about IE but in chrome with that fiddle I'm getting: Uncaught TypeError: Cannot read property 'value' of undefined –ars265 Sep 3 '13 at 14:03 This has been answered in [here][1] [1]: stackoverflow.com/a/13818214/2621192 –Jaypal Sep 3 '13 at 14:04 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote This question has been asked and answered a lot. You can't directly modify the innerHtml of tables in IE8. See: InnerHTML issue in IE8 and below Why is document.getElementById('tableId').innerHTML not working in IE8? etc... share|improve this answer answer So here's a basic example of what I'm trying to do, as the real one is long. The whole purpose of https://www.sitepoint.com/community/t/ie-unknown-runtime-error-with-innerhtml/3432 this was to avoid going to the database again. There is a http://www.theogray.com/blog/2009/06/internet-explorer-unknown-runtime-error page that loads an article from a Java bean (J2EE that is) with a headline and body property. So I've placed a span around the headline with an id and the same with the body, I think it's a div on the body, doesn't really matter, problem is the same. I runtime error wrote a javascript function to create a form, a text input for the headline, and a textarea for the body, all in a hidden div, and then the function submits the form to a popup and creates a printer friendly version of the page. I didn't want to have to retrieve the article from the database when I can just send it in the unknown runtime error post. This works very well in Firefox, then I tried it in IE and got the very useful error "Unknown runtime error", thanks. Here's a small example that produces the same error. HelloWorld innerHTML Test I've seen similar threads on this problem and the general solution is to wrap things in a div tag, but I had tried this which seems to work in IE but gives blank text area in Firefox. At this point I decided to cut my losses on this and just do it on the backend side of things which I far more control over. But I'd like to know if there is a good solution for this. busy 2007-08-17 02:12:59 UTC #2 instead of innerHTML try this bodyText.value='whatever'; I had this problem recently. r51 2007-08-17 07:34:47 UTC #3 You shouldn't put block level elements inside inline elements. So your span shouldn't contain h3 and h1. There should be no problem s fair share of annoying Microsoft error messages, so I wasn't too suprised when I randomly hit the following Javascript error in IE8: Unknown runtime error Even better, if I switched to IE7 compatibility mode I got the old: [object error] Having tracked down the line that was causing the problem, it appears that the Javascript hook into the DOM is rather more strict (or maybe buggy!) when setting innerHTML than when using document.write. document.write The following line of code works and displays the expected output: document.write(' Hello'); innerHTML And the following works as expected in all browsers except IE: // Done when the page is initially displayed document.write(''); // Done in a seperate function that works out what should really go in extraNote var note = document.getElementById("extraNote"); note.innerHTML=' Hello'; The fix Having worked out why IE was being annoying, the fix was very simple... replace with ... but it's obvious IE8 still has random IEisms, and proves that when it comes to supporting IE, that even now you have to fully test even the most minor of code changes (extraNote used to be a table cell rather than a paragraph i.e. ). Update: Just checked the IE Programming Bugs Wiki and see that this is apparently "by design" - "Can't put invalid HTML in the document: You cannot assign a string to innerHTML or outerHTML that contains invalid HTML. For example, trying to replace the content of the P element with another P will fail. A P element can only contain text and inline elements. However, replacing the entire P element with another P would work just fine." This seems like a very wierd limitation, especially as it's possible to edit the DOM directly and create a | within a
tag in IE, but there we go. Case closed I guess. Share| By Theo Gray on June 1, 2009 | Permalink | Comment Reader Comments Skip to form March 27, 2010, Kelly McIvor says:Thanks for the post! This was precisely what what happening for me. I was trying to replace innerHTML with a element. Using two |