tags:

views:

60

answers:

3

Hi, I have that JavaScript code:

  var state = 'hidden';
    function Show_Picture() 
    {
        if (state == 'visible') 
            state = 'hidden';
        else 
            state = 'visible';
        document.getElementById('loader').style.visibility = state;
    }

'loader' is the

<img alt="" id="loader" src="file:///D:/ajax-loader.gif"/>

Why that code doesn't work on FF ? Ont the IE it works OK.

Here's the code: http://pastebin.com/m38aa1847

A: 

Use a framework. They take care of all this cross-browser business for you.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"&gt;&lt;/script&gt;

<script>
function Show_Picture() {
    $('loader').toggle()
}
</script>
Diodeus
A: 

Try this instead:

var state = 'hidden';

function Show_Picture() 

{

    if (state == '') 

        state = 'hidden';

    else 

        state = '';

    document.getElementById('loader').style.visibility = state;

}
zincorp
nope, it doesn't work too
Tony
A: 

I actually can't reproduce your bug. I copy-pasted your code from pastebin and ran it on FF 3.5.6 - the only thing I changed was the image source to a local image of my own.

Are you trying to debug it on FF at all? Try running it with Firebug open and see if any errors are reported.

Test the response code of the image request, too. Perhaps it's the file:// protocol that isn't working correctly.

EDIT

Yup - just tested it. When I changed the image's src to a fully-qualified local path (i.e., one with file://) it doesn't show up in Firefox. Your Javascript works fine - just change the image path.

Peter Bailey
yes, it works ! :) thanks !
Tony