Results 1 to 4 of 4

Thread: Javascript doesen't run on Mozilla firefox

  1. #1
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 12
    Posts
    140

    Javascript doesen't run on Mozilla firefox

    I have some javascript that run on Chrome but on Mozilla firefox it just doesen't work. Here is js code:

    Code:
    <script type="text/javascript">
    function Get_help() {
    var info = "/info";
    var help = "/help";
    var info_website = "This webpage is developed for helping every coder to get most common things he need for making web pages. This webpage is created by Mr.Joker for CSS Help forum members. It's not allowed to use this webpage for your forums. This page is only for members of CSS Help forum.";
    var help_website = "To use this webpage you have to type slash (/) and then some word that is allready registred as default value.\n " + "\n" + "List of default values:\n " + "1. /info\n" + "2. /help\n" + "3. /html\n" + "4. /css\n" + "5. /colors\n" + "6. /fonts\n";
    var get_input = document.forms[0].search.value;
    if (get_input == info) {
    document.getElementById('paragraph').innerText = info_website;
    } else if(get_input == help) {
    document.getElementById('paragraph').innerText = help_website;
    }
    }
    </script>
    Then I have a button which should run that javascript but it doesen't only on Mozilla:

    Code:
    <input type="button" class="button" value="Search" onClick="Get_help();">
    And there is paragraph with ID:

    Code:
    <p id="paragraph"></p>

  2. #2
    Addicted Member coothead's Avatar
    Join Date
    Oct 07
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    216

    Re: Javascript doesen't run on Mozilla firefox

    Hi there Mr.Joker,

    your problem is "innerText" which, unfortunately, is IE code,

    I would suggest that you replace it with "innerHTML" or the DOM "firstChild.nodeValue".

    If you decide to use the DOM option then change this...
    Code:
    <p id="paragraph"></p>
    ...to this...
    Code:
    <p id="paragraph">&nbsp;</p>
    ...just to be safe.
    Last edited by coothead; Aug 2nd, 2012 at 04:14 PM. Reason: typing error

  3. #3
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 12
    Posts
    140

    Re: Javascript doesen't run on Mozilla firefox

    Thank you man. I now have to change every \n separator because I have to use break html tag. But it's ok. Thanks again.

  4. #4
    Addicted Member coothead's Avatar
    Join Date
    Oct 07
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    216

    Re: Javascript doesen't run on Mozilla firefox

    No problem, you're very welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •