Thursday, March 23, 2006

JavaScript Tip

When dynamically creating an anchor in javascript, be sure to set not only the innerText (the text that appears between the open and closing tags), but also the innerHTML. Otherwise, if you try to view the said anchor in Firefox, it doesn't render.

Example:

var linkClose = document.createElement("A");

linkClose.href = "javascript:void(null)";
linkClose.innerText = "Close Window";
linkClose.innerHTML = "Close Window";

No comments: