Problem with loading image in FF-Win

T

Tim Streater

The statement:

myImage.src = "wiggy.jpg";

appears to be a no-operation in FireFox 2.0.0.14 under XP. Works fine in
IE7 (XP) and on the Mac under Safari and FF.

myImage points to an <img ...> and wiggy.jpg is in the same directory as
the HTML file (a network mount, from which all these browsers were
accessing it).

I did read somewhere that JS is not supposed to have access to the local
filesystem and therefore the operation should be disallowed anyway,
however, this sort of operation seems to be widespread. See, e.g.:

http://www.webdevelopersnotes.com/tips/html/42.php3

Any pointers welcome.
 
M

Martin Honnen

Tim said:
The statement:

myImage.src = "wiggy.jpg";

appears to be a no-operation in FireFox 2.0.0.14 under XP. Works fine in
IE7 (XP) and on the Mac under Safari and FF.

myImage points to an <img ...> and wiggy.jpg is in the same directory as
the HTML file (a network mount, from which all these browsers were
accessing it).

If FF on the Mac works then it is hard to tell why it does not work with
FF on Win. Have you checked with DOM inspector that the src property is
indeed changed? Have you checked the error console (just to make sure
there is no script error or security problem shown)?
 
T

Tim Streater

Martin Honnen said:
If FF on the Mac works then it is hard to tell why it does not work with
FF on Win.
Quite!

Have you checked with DOM inspector that the src property is
indeed changed?

To get this I re-installed FF. My <img> has no src attribute under XP.
FF-Mac shows the expected value for this attribute.

If I give the <img> an src attribute in the source, giving some
non-existent file, then that is what show up in the DOM inspector.
Setting it to something else has no effect - the src attribute is
unaltered.
Have you checked the error console (just to make sure
there is no script error or security problem shown)?

Yes - the error console shows nothing.

Clutching at straws I requested colleagues to try it - and for them,
with FF under XP, it works. So it looks like it's limited to my PC, but
I'm damned if I can see why.
 
Á

Álvaro G. Vicario

Tim Streater escribió:
The statement:

myImage.src = "wiggy.jpg";

appears to be a no-operation in FireFox 2.0.0.14 under XP. Works fine in
IE7 (XP) and on the Mac under Safari and FF.

myImage points to an <img ...> and wiggy.jpg is in the same directory as
the HTML file (a network mount, from which all these browsers were
accessing it).

I did read somewhere that JS is not supposed to have access to the local
filesystem and therefore the operation should be disallowed anyway,
however, this sort of operation seems to be widespread. See, e.g.:

http://www.webdevelopersnotes.com/tips/html/42.php3

In a previous message you asked advice on how to insert a picture from
the client file system in a page from an Internet site. This article
talks about rollovers, which has absolutely nothing to do with it.

Firefox does allow to dynamically change the src attribute of an <img>
tag. But it won't display a client image in a server document, not even
statically:

<img src="file:///C:/Foo/tmp/paisaje01.jpg" width="100" height="100"
alt="" title="">

This works locally but not once you publish the page. If plain HTML
won't allow it, there's no point in generating that HTML with JavaScript.

I'm not sure if you can circumvent it with iframes or any other trick,
but you should first test with simple plain HTML.

BTW, "wiggy.jpg" is a relative path: it will only load the file from
your computer until you fetch it through a web server.
 
M

Martin Honnen

Tim said:
Clutching at straws I requested colleagues to try it - and for them,
with FF under XP, it works. So it looks like it's limited to my PC, but
I'm damned if I can see why.

The is a preference dom.disable_image_src_set which is probably true for
your Firefox profile. Type
about:config
into the location bar and search for that preference.
 
T

Tim Streater

Álvaro G. Vicario said:
Tim Streater escribió:

In a previous message you asked advice on how to insert a picture from
the client file system in a page from an Internet site. This article
talks about rollovers, which has absolutely nothing to do with it.

It has a button that says "Hover over me" or words to that effect, and
the trick they wish to demonstrate (the button changing) did not work on
my PC. This was an example of my problem. Sorry - I should have made
that clearer.
Firefox does allow to dynamically change the src attribute of an <img>
tag. But it won't display a client image in a server document, not even
statically:

<img src="file:///C:/Foo/tmp/paisaje01.jpg" width="100" height="100"
alt="" title="">

This works locally but not once you publish the page. If plain HTML
won't allow it, there's no point in generating that HTML with JavaScript.

Of course, but at the moment I am researching what technique to be used
in a larger app, which already exists. I can use an <input type=file> to
ask a filename, and If I could just have a Submit button then the form's
action can process the image, no problem. But in this particular
example, I can't use a submit button, for reasons to do with the
pre-existing app.

The image will be added to a database record. In essence I am going to
have to get the it from the user's file system, hold it in a JS variable
while the user possibly makes many other changes, on other pages, and
then when the user wants to save all their changes, store it back in the
database record, which is on the server. The app, which I wrote, already
exists - I am just extending it slightly so the user can have a picture
in the record.
I'm not sure if you can circumvent it with iframes or any other trick,
but you should first test with simple plain HTML.

An iframe is what I am going to have to try.
BTW, "wiggy.jpg" is a relative path: it will only load the file from
your computer until you fetch it through a web server.

Yes - this was just an example.

Now I know that this issue seems to be limited to my own PC, I'll stop
trying to fix it (re-installing FF did not help).

Thanks for your feedback.
 
T

Tim Streater

Martin Honnen said:
The is a preference dom.disable_image_src_set which is probably true for
your Firefox profile. Type
about:config
into the location bar and search for that preference.

Thanks - that's really helpful. I'll look at that tomorrow at work.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top