Innertext' Works in Ie, But Not in Firefox

innerText' works in IE, but not in Firefox

Firefox uses the W3C-compliant textContent property.

I'd guess Safari and Opera also support this property.

Why is .innerText not working in Firefox?

innerText is the "old Internet Explorer" way of doing it.

Try textContent instead. Ideally you should use elem.textContent || elem.innerText, but if you're using jQuery you can just do jQuery("#the_id_here").text().

children.innerText is not working in firefox

Use textContent instead of innerText

Javascript with Firefox innerText issue

While innerText is non-standard, it significantly differs from textContent, because first one is doing pretty printing (for example, <br/> are converted to new lines), while second one - is not.

So, while common wisdom is to use:

var toUsername = anchor.innerText || anchor.textContent;

or some kind of wrapper, it can probably be smarter to just use jQuery's .text or its analog from other library you are using.

innerHTML works in IE and Firefox, but not Chrome

You should use some modern Javascript library. It guards you from many of those small differences between browsers. I like jQuery.

So, with jquery your code

window.onload = function() {
var url = "http://----.freeiz.com/gbSales/sales.json";
var request = new XMLHttpRequest();
request.open("GET", url);
request.onload = function () {
if (request.status == 200) {
updateSales(request.responseText);
}
};
request.send(null);
}
function updateSales(responseText) {
var salesDiv = document.getElementById("sales");
salesDiv.innerHTML = responseText;
}

becomes

$(document).load(function() {
var url = "http://----.freeiz.com/gbSales/sales.json";

$.get(url, {}, function(data) {
$('#sales').html(data);
});
});

Shorter, cleaner and works in all browsers!

Inline JavaScript works in Chrome but not in Firefox

The issue comes from innerText.

See: 'innerText' works in IE, but not in Firefox

You should use jQuery or use innerHTML.



Related Topics



Leave a reply



Submit