JavaScript image loading problem in Firefox

C

chris

Firefox seems to be restricting JavaScript image loading. The following
code works fine in all browsers except Firefox:

function loadImage()
{
var objIcon = document.createElement( 'IMG' );
objIcon.src = "/techJournal/firefoxIcon.png";
document.body.appendChild( objIcon );
}

The image simply doesn't load, as you will see at:
http://www.firethefox.co.uk/techJournal/firefoxImageJavaScript.html

Could it be that the security lockdowns in the latest version of
Firefox prevent image loading in JavaScript? If so, does anyone know a
workaround that I can introduce into my code?

I'd be grateful for your help

Chris Beach
 
L

Lee

(e-mail address removed) said:
Firefox seems to be restricting JavaScript image loading. The following
code works fine in all browsers except Firefox:

function loadImage()
{
var objIcon = document.createElement( 'IMG' );
objIcon.src = "/techJournal/firefoxIcon.png";
document.body.appendChild( objIcon );
}

The image simply doesn't load, as you will see at:
http://www.firethefox.co.uk/techJournal/firefoxImageJavaScript.html

Could it be that the security lockdowns in the latest version of
Firefox prevent image loading in JavaScript? If so, does anyone know a
workaround that I can introduce into my code?

I see the image in Firefox 1.5.
Check your browser option settings.
If the user has chosen to disable images, the workaround is to ask them
to enable them.
 
C

chris

Images are enabled in my browser, and the problem occurs whether or not
the "for the originating site only" option is ticked.

Any more ideas, anyone?
 
L

Lee

(e-mail address removed) said:
Images are enabled in my browser, and the problem occurs whether or not
the "for the originating site only" option is ticked.

Any more ideas, anyone?

I guess I have to ask if Javascript is also enabled.
Do you see any messages in the Javascript console?
 
T

Thomas 'PointedEars' Lahn

Firefox seems to be restricting JavaScript image loading. The following
code works fine in all browsers except Firefox:

function loadImage()
{
var objIcon = document.createElement( 'IMG' );
objIcon.src = "/techJournal/firefoxIcon.png";
document.body.appendChild( objIcon );
}


WFM. Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051217
Debian/1.5.dfsg-2 Firefox/1.5 Mnenhy/0.7.3.0
Could it be that the security lockdowns in the latest version of
Firefox prevent image loading in JavaScript?

Check Edit, Preferences, Content, Load Images.
Try Ctrl+Shift+r. Clear the cache (directory).
If so, does anyone know a workaround that I can introduce into my code?

Fortunately for other users, there is none.


PointedEars
 
C

chris

My UA is Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8)
Gecko/20051111 Firefox/1.5

I have tried the steps you pointed out but to no avail

My employer puts restrictions and enforced configuration on certain
software. It could be that these apply to Firefox and are causing the
problem I'm seeing. Thanks for looking into this, guys. I guess the
issue isn't widespread so I probably shouldn't be worried about it.
 
C

chris

The problem has been identified by Ben Basson, who commented on my
blog:

Having the pref "dom.disable_image_src_set" set as the boolean value
'true' in about:config will cause your script to fail.

IIRC, this option was removed from the interface because there's no
logical reason that anyone would want to disable this behaviour. It's
default value is set to 'false', i.e. changing the src of an image is
allowed by default.

I can't think of a workaround, but I sort of hope that there isn't one,
since that would somewhat devalue the preference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,110
Latest member
OdetteGabb
Top