Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a problem using JavaScript that seems to function properly in IE but not in Mozilla Firefox..

Following is a simple example for that kind of JavaScript code:

XML
<head>
    <title>Helo World</title>
        <script type='text/javascript'>
            function ShowSelection() {
        try{
            alert('Your selection is ' + SelectColor.value);
            BodyContent.style.backgroundColor = SelectColor.value;
            }
            catch(e){alert('An error has occurred: '+e.message)}
    }
    </script>
</head>
<body>
    <div id="BodyContent">

        <hr />
         Select a color theme:
        <select id="SelectColor">
            <option value="white">White</option>
            <option value="yellow">Yellow</option>
            <option value="silver">Silver</option>
        </select>
        <input id="SelectionBTN" type="button" value="Select" onclick="ShowSelection()"  />
     br mode="hold" />  </div>
</body>
</html>


You can try this and you can see EVERYTHING WORKS FINE WITH IE, but NOT with Mozilla Firefox. In Firefox it gives an error that saying "function is not defined". Why? How to fix it??
Posted
Comments
Albin Abel 17-Mar-11 15:17pm    
Which version of firebox it is?. if it is older version then you may need to use the document.getElementById method

1 solution

Since you are having a problem with FF, are you familier with firebug[^]? If not why not get it and debug it yourself. It is a great javascript debugging tool, I am sure you will like it.
 
Share this answer
 
Comments
Espen Harlinn 17-Mar-11 19:34pm    
Good advice, my 5
Yusuf 18-Mar-11 8:45am    
Thanks, Firebug is simply amazing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900