This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes innerHTML does not work in IE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "innerHTML does not work in IE?" Watch "innerHTML does not work in IE?" New topic
Author

innerHTML does not work in IE?

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Hi I am facing a simple problem it seems as if IE cant recognize my innerHTML and returns with a run time error it works in firefox and chrome
Here is what i am trying to do

the string gets displayed in the console but i get a run time error on the next line.
The element username is present in a div element. any ideas why i am getting this ??

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Not enough info. What's in rx? Have you verified that the element is being fetched? What's the exact error? Just saying "I got an error" isn't helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Marcin Kwiatkowski
Ranch Hand

Joined: Aug 06, 2007
Posts: 32

innerHTML is broken in IE and depending on your use case there are different workarounds. For example:
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Bear Bibeault wrote:Not enough info. What's in rx? Have you verified that the element is being fetched? What's the exact error? Just saying "I got an error" isn't helpful.


Rx is a string which the java function received as a response from an http asynch request. And yes i verified it. by using console.log(rx) also it works in firefox but not in IE . All i get is "runtime error" according to IE 8.0
Marcin Kwiatkowski
Ranch Hand

Joined: Aug 06, 2007
Posts: 32

You have to open Developers Tools (F12) in order to access console in IE8.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What is username? Is it a input, div, etc?
What is the string you are trying to add to the page?

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Rajesh Khan wrote:Rx is a string which the java function received as a response from an http asynch request.
That does not answer my question.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: innerHTML does not work in IE?
 
Similar Threads
How to set html value to Dojo digit.Editor
Need a little help with the map container
Help documenting this method
Execute JavaScript function present in HTML fragment loaded using AJAX
responseXML.documentElement returns null object