-2

I have an applcation built using Javascript and HTML5. I also have some scripts included that is to be executed on button click.

The application seems to be working fine on chrome but when I tried to run on Firefox it fails. I tried to debug and found out that document.getElementByID() returns null value. But the element is already existing in the body of the document.

Info:
Platform : Firefox
Version : Mozilla Firefox ESR
OS : Windows 7 64bit

I did refer to several similar questions on stackoverflow and found that the script part has to be within the body. But I am wondering if it is the case, then how could it work on Chrome?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Sangamesh Hs
  • 1,447
  • 3
  • 24
  • 39
  • 2
    it would be more helpful if you could create a jsfiddle – Amit Joki May 27 '15 at 13:39
  • 2
    Post the actual code involved. – Pointy May 27 '15 at 13:39
  • We don't need a jsFiddle. Post relevant code in the question and you'll get your answer. –  May 27 '15 at 13:51
  • Could be many reasons, post code. One thing you could be doing is trying to get an element before it's loaded into the DOM. Another is just that you spelled your ID wrong in your HTML/JS. If you post code, myself and many others will assist you. – deadboy May 27 '15 at 13:54
  • Hey Guys, I have updated the question. @EvinUgur The ID is correct. It is working on chrome but not on firefox. – Sangamesh Hs May 27 '15 at 13:56
  • By the way I would like to ask the down voters to please be kind to let me know "How can this be off the topic?" Thanks – Sangamesh Hs May 27 '15 at 13:58
  • The code should be posted **here**, as part of the question, and not as a link to some other site. – Pointy May 27 '15 at 13:58
  • @SangameshHs I stepped through your function in FireFox's debugger and the call to getElementById did not return null it returned a valid reference to the appropriate HTML element. – deadboy May 27 '15 at 14:03
  • 1
    [See this SO question.](http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox) The problem is not with `.getElementById()`, it's with the use of `.innerText` which is not supported by Firefox. – Pointy May 27 '15 at 14:04
  • @Pointy You are right. Can you post this as an answer? – Sangamesh Hs May 27 '15 at 14:26
  • Post code *directly* in your question. Don't just link to it. You've asked enough questions to know this. –  May 30 '15 at 17:28

1 Answers1

2

The property .innerText is not supported by Firefox. I have added the code you were referring to below so others can have a better sense of context on what is being discussed.

function UF_FC_OIST() {
    var rd1 = "BUTTON_GROUP_ITEM_3_btn0_acButton";
    if (document.getElementById(rd1)) {
        var valrd1 = document.getElementById(rd1);
        valrd2 = valrd1.innerText; // <-------------- NOT SUPPORTED BY FIREFOX
        if (valrd2 == 'Umsatz-Forecast ohne IST (Budget) generieren') {
            valrd2 = "ZLF_FC_INIT_OHNE_IST";
        }
    } else {
        console.log(error);
    }
    window.open("url" + valrd2)
};

Additional resources on innerText:

http://quirksmode.org/dom/html/#t07

http://perfectionkills.com/the-poor-misunderstood-innerText/

xengravity
  • 3,501
  • 18
  • 27