Click here to Skip to main content
15,887,596 members
Home / Discussions / JavaScript
   

JavaScript

 
NewsSorry Pin
Olli Ikonen30-Apr-11 10:01
Olli Ikonen30-Apr-11 10:01 
GeneralRe: What in a world i'm doing wrong... Pin
DaveAuld30-Apr-11 19:58
professionalDaveAuld30-Apr-11 19:58 
AnswerRe: What in a world i'm doing wrong... Pin
Luc Pattyn30-Apr-11 21:27
sitebuilderLuc Pattyn30-Apr-11 21:27 
AnswerDuplicate - Your question also in Q/A section Pin
thatraja30-Apr-11 7:04
professionalthatraja30-Apr-11 7:04 
GeneralRe: How can i refresh status bar information... Pin
thatraja30-Apr-11 8:22
professionalthatraja30-Apr-11 8:22 
NewsSorry Pin
Olli Ikonen30-Apr-11 10:01
Olli Ikonen30-Apr-11 10:01 
Question[RESOLVED] innerHTML messed up Pin
CodingLover27-Apr-11 18:58
CodingLover27-Apr-11 18:58 
AnswerRe: innerHTML messed up Pin
AspDotNetDev27-Apr-11 19:43
protectorAspDotNetDev27-Apr-11 19:43 
Can you provide an example that doesn't work in IE? Until then, here are some general guidelines:

Use "innerHTML", not "innerHtml".

Use createElement, set its innerHTML, then add it to the DOM, rather than adding the element to the DOM then setting the innerHTML. So, do this:
JavaScript
// Create replacement DIV.
var newDiv = document.createElement("div");
newDiv.innerHTML = "Hello, <b>World</b>.";


// Insert replacement DIV.
var oldDiv = document.getElementById("myDiv");
oldDiv.parentNode.insertBefore(newDiv, oldDiv);


// Remove old DIV.
oldDiv.parentNode.removeChild(oldDiv);


// Give replacement DIV same ID as old DIV.
newDiv.id = "myDiv";

Alternatively, avoid the use of innerHTML completely:
JavaScript
// Get DIV.
var mainDiv = document.getElementById("myDiv");


/* TODO: You may want to empty the children here. */
    

// Append "Hello, ".
mainDiv.appendChild(document.createTextNode("Hello, "));


// Append "<b>Hello</b>".
var boldWorld = document.createElement("b");
boldWorld.appendChild(document.createTextNode("World"));
mainDiv.appendChild(boldWorld);


// Append ".".
mainDiv.appendChild(document.createTextNode("."));

Here is a hack that may or may not work:
JavaScript
// Get DIV.
var mainDiv = document.getElementById("myDiv");


// Set innerHTML.
mainDiv.innerHTML = "Hello <b>World</b>.";


// Set innerHTML again (IE hack).
mainDiv.innerHTML = mainDiv.innerHTML;

Depending on your specific issue, I've also seen hacks that modify the z-index so the browser knows to refresh the content.

GeneralRe: innerHTML messed up Pin
CodingLover27-Apr-11 21:09
CodingLover27-Apr-11 21:09 
AnswerRe: innerHTML messed up Pin
Gerben Jongerius27-Apr-11 20:53
Gerben Jongerius27-Apr-11 20:53 
GeneralRe: innerHTML messed up Pin
CodingLover27-Apr-11 21:11
CodingLover27-Apr-11 21:11 
GeneralRe: innerHTML messed up Pin
Gerben Jongerius27-Apr-11 21:47
Gerben Jongerius27-Apr-11 21:47 
GeneralRe: innerHTML messed up Pin
CodingLover27-Apr-11 23:11
CodingLover27-Apr-11 23:11 
QuestionDynamics CRM 2011 - Cutomizing datetime picker in CRM Form [SOLVED] Pin
phil.o27-Apr-11 4:55
professionalphil.o27-Apr-11 4:55 
AnswerRe: Dynamics CRM 2011 - Cutomizing datetime picker in CRM Form Pin
Graham Breach27-Apr-11 12:06
Graham Breach27-Apr-11 12:06 
GeneralRe: Dynamics CRM 2011 - Cutomizing datetime picker in CRM Form Pin
phil.o27-Apr-11 20:39
professionalphil.o27-Apr-11 20:39 
Questionjquery ajaxupload Pin
dbongs25-Apr-11 23:46
dbongs25-Apr-11 23:46 
AnswerRe: jquery ajaxupload Pin
Monjurul Habib27-Apr-11 9:42
professionalMonjurul Habib27-Apr-11 9:42 
Questioncalander Pin
amit.veterans23-Apr-11 21:28
amit.veterans23-Apr-11 21:28 
AnswerRe: calander Pin
thatraja24-Apr-11 18:06
professionalthatraja24-Apr-11 18:06 
AnswerRe: calander Pin
RakeshMeena9-Jun-11 19:36
RakeshMeena9-Jun-11 19:36 
QuestionAll code on one line? Pin
#realJSOP23-Apr-11 1:04
mve#realJSOP23-Apr-11 1:04 
AnswerRe: All code on one line? Pin
Not Active23-Apr-11 3:12
mentorNot Active23-Apr-11 3:12 
GeneralRe: All code on one line? Pin
#realJSOP23-Apr-11 3:37
mve#realJSOP23-Apr-11 3:37 
GeneralRe: All code on one line? Pin
Not Active23-Apr-11 4:36
mentorNot Active23-Apr-11 4:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.