Problem with loading image in FF-Win

Discussion in 'Javascript' started by Tim Streater, May 22, 2008.

  1. Tim Streater

    Tim Streater Guest

    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.
     
    Tim Streater, May 22, 2008
    #1
    1. Advertising

  2. Tim Streater wrote:
    > 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)?


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 22, 2008
    #2
    1. Advertising

  3. Tim Streater

    Tim Streater Guest

    In article <4835682f$0$6778$-online.net>,
    Martin Honnen <> wrote:

    > Tim Streater wrote:
    > > 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.


    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.
     
    Tim Streater, May 22, 2008
    #3
  4. 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.



    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --
     
    Álvaro G. Vicario, May 22, 2008
    #4
  5. Tim Streater wrote:

    > 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 22, 2008
    #5
  6. Tim Streater

    Tim Streater Guest

    In article <g142qg$skm$>,
    "Álvaro G. Vicario" <> wrote:

    > 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.


    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.
     
    Tim Streater, May 22, 2008
    #6
  7. Tim Streater

    Tim Streater Guest

    In article <48359376$0$6518$-online.net>,
    Martin Honnen <> wrote:

    > Tim Streater wrote:
    >
    > > 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.


    Thanks - that's really helpful. I'll look at that tomorrow at work.
     
    Tim Streater, May 22, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ARaman
    Replies:
    1
    Views:
    407
    Mike Wahler
    Oct 23, 2003
  2. Chris Lyon
    Replies:
    0
    Views:
    355
    Chris Lyon
    Oct 7, 2003
  3. Ringwraith
    Replies:
    4
    Views:
    967
    Ringwraith
    Jan 27, 2004
  4. Krist
    Replies:
    6
    Views:
    798
    Arne Vajhøj
    May 7, 2010
  5. edfialk
    Replies:
    0
    Views:
    210
    edfialk
    May 10, 2007
Loading...

Share This Page