Professional Web Applications Themes

Loading client-side images for use in Javascript - ASP.NET General

Ok, I'll play the dumb guy.... if your script is running on the server under the testapp application, why isn't the source 'Images/down.gif' (Path relative) to the application and the full path on the server? At least if nothing else, this would make the code more transportable to serveral hosts without having to rely on the fact that inetpub/wwwroot is the actual root of the web server (which it is not on my machines). Cheers "John" <ab.com> wrote in message news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl... > Hi all, > > I did post this a short while back and received a couple of answers ...

  1. #1

    Default Re: Loading client-side images for use in Javascript

    Ok, I'll play the dumb guy.... if your script is running on the server under
    the testapp application, why isn't the source 'Images/down.gif' (Path
    relative) to the application and the full path on the server? At least if
    nothing else, this would make the code more transportable to serveral hosts
    without having to rely on the fact that inetpub/wwwroot is the actual root
    of the web server (which it is not on my machines).

    Cheers

    "John" <ab.com> wrote in message
    news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl...
    > Hi all,
    >
    > I did post this a short while back and received a couple of answers but
    I'm
    > still stuck. What I've done is pasted the source below. This is what
    appears
    > in my html doent when the source is viewed.
    >
    > <script>
    > var imgdown = new Image;
    > imgdown.src = 'C:\Inetpub\wwwroot\testapp\Images\down.gif';
    > </script>
    >
    > Later on, if a user clicks on an area, some Javascript runs and it
    attempts
    > to replace that same area with the 'pre-populated' imgdown image object
    but
    > nothing shows.
    >
    > The path to the image is correct. What am I doing wrong here?
    >
    > Regards
    > John.
    >
    >

    j0vo Guest

  2. #2

    Default Re: Loading client-side images for use in Javascript

    Hi,

    I did actually try "..\Images\down.gif" and "Images/down.gif" and both don't
    work for me. WHat now?

    Regards
    John.

    "j0vo" <nospamjovoeostar.com> wrote in message
    news:eynpWHTTDHA.3116TK2MSFTNGP10.phx.gbl...
    > Ok, I'll play the dumb guy.... if your script is running on the server
    under
    > the testapp application, why isn't the source 'Images/down.gif' (Path
    > relative) to the application and the full path on the server? At least if
    > nothing else, this would make the code more transportable to serveral
    hosts
    > without having to rely on the fact that inetpub/wwwroot is the actual root
    > of the web server (which it is not on my machines).
    >
    > Cheers
    >
    > "John" <ab.com> wrote in message
    > news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl...
    > > Hi all,
    > >
    > > I did post this a short while back and received a couple of answers but
    > I'm
    > > still stuck. What I've done is pasted the source below. This is what
    > appears
    > > in my html doent when the source is viewed.
    > >
    > > <script>
    > > var imgdown = new Image;
    > > imgdown.src = 'C:\Inetpub\wwwroot\testapp\Images\down.gif';
    > > </script>
    > >
    > > Later on, if a user clicks on an area, some Javascript runs and it
    > attempts
    > > to replace that same area with the 'pre-populated' imgdown image object
    > but
    > > nothing shows.
    > >
    > > The path to the image is correct. What am I doing wrong here?
    > >
    > > Regards
    > > John.
    > >
    > >
    >
    >

    John Guest

  3. #3

    Default Re: Loading client-side images for use in Javascript

    Hi

    var imgDown = new Image();
    imgDown.src = "PATH/Image.gif";

    setNewImg(e){
    e.src = imgDown.src;
    }

    <img onclick="setNewImg(this)">

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "John" <ab.com> wrote in message
    news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl...
    > Hi all,
    >
    > I did post this a short while back and received a couple of answers but
    I'm
    > still stuck. What I've done is pasted the source below. This is what
    appears
    > in my html doent when the source is viewed.
    >
    > <script>
    > var imgdown = new Image;
    > imgdown.src = 'C:\Inetpub\wwwroot\testapp\Images\down.gif';
    > </script>
    >
    > Later on, if a user clicks on an area, some Javascript runs and it
    attempts
    > to replace that same area with the 'pre-populated' imgdown image object
    but
    > nothing shows.
    >
    > The path to the image is correct. What am I doing wrong here?
    >
    > Regards
    > John.
    >
    >

    Vidar Petursson Guest

  4. #4

    Default Re: Loading client-side images for use in Javascript

    Hi Vidar,

    Please excuse the ignorance but what should I use in the 'PATH' part? The
    stringbuilder section where I write the javascript text is from within a
    user control which is in another folder off the web root.

    Regards
    John.


    "Vidar Petursson" <thekingicysoft.com> wrote in message
    news:#wg$#vTTDHA.632TK2MSFTNGP12.phx.gbl...
    > Hi
    >
    > var imgDown = new Image();
    > imgDown.src = "PATH/Image.gif";
    >
    > setNewImg(e){
    > e.src = imgDown.src;
    > }
    >
    > <img onclick="setNewImg(this)">
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Internet Client & Controls MVP
    > ==============================
    > "John" <ab.com> wrote in message
    > news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl...
    > > Hi all,
    > >
    > > I did post this a short while back and received a couple of answers but
    > I'm
    > > still stuck. What I've done is pasted the source below. This is what
    > appears
    > > in my html doent when the source is viewed.
    > >
    > > <script>
    > > var imgdown = new Image;
    > > imgdown.src = 'C:\Inetpub\wwwroot\testapp\Images\down.gif';
    > > </script>
    > >
    > > Later on, if a user clicks on an area, some Javascript runs and it
    > attempts
    > > to replace that same area with the 'pre-populated' imgdown image object
    > but
    > > nothing shows.
    > >
    > > The path to the image is correct. What am I doing wrong here?
    > >
    > > Regards
    > > John.
    > >
    > >
    >
    >

    John Guest

  5. #5

    Default Re: Loading client-side images for use in Javascript

    I did not see your prior posts, but if the script is on the executing on
    the web server in the context of the app, then things should be cool with
    path absolute or relative. But your subject line indicates that perhaps the
    script is a client-side script running in the browser. If it is a script
    running in the browser, then I would not ever expect path relative or
    absolute addressing from the client script to ever be able to directly
    access a file on the web server like you have it.

    Instead, I would imagine the .NET aspx to script something like

    string newPath = Request.Application.Path + "/images/down.gif";

    where the above body is specified in a runat=server block of code -- so that
    the application path can be rewritten by the web server so that the client
    browser can load it via URL.


    That is my guess, not knowing anything about your application -- Hope it
    helps, good luck


    "John" <ab.com> wrote in message
    news:OcQiOnTTDHA.1688TK2MSFTNGP11.phx.gbl...
    > Hi,
    >
    > I did actually try "..\Images\down.gif" and "Images/down.gif" and both
    don't
    > work for me. WHat now?
    >
    > Regards
    > John.
    >
    > "j0vo" <nospamjovoeostar.com> wrote in message
    > news:eynpWHTTDHA.3116TK2MSFTNGP10.phx.gbl...
    > > Ok, I'll play the dumb guy.... if your script is running on the server
    > under
    > > the testapp application, why isn't the source 'Images/down.gif' (Path
    > > relative) to the application and the full path on the server? At least
    if
    > > nothing else, this would make the code more transportable to serveral
    > hosts
    > > without having to rely on the fact that inetpub/wwwroot is the actual
    root
    > > of the web server (which it is not on my machines).
    > >
    > > Cheers
    > >
    > > "John" <ab.com> wrote in message
    > > news:e91gP9STDHA.560TK2MSFTNGP10.phx.gbl...
    > > > Hi all,
    > > >
    > > > I did post this a short while back and received a couple of answers
    but
    > > I'm
    > > > still stuck. What I've done is pasted the source below. This is what
    > > appears
    > > > in my html doent when the source is viewed.
    > > >
    > > > <script>
    > > > var imgdown = new Image;
    > > > imgdown.src = 'C:\Inetpub\wwwroot\testapp\Images\down.gif';
    > > > </script>
    > > >
    > > > Later on, if a user clicks on an area, some Javascript runs and it
    > > attempts
    > > > to replace that same area with the 'pre-populated' imgdown image
    object
    > > but
    > > > nothing shows.
    > > >
    > > > The path to the image is correct. What am I doing wrong here?
    > > >
    > > > Regards
    > > > John.
    > > >
    > > >
    > >
    > >
    >
    >

    j0vo Guest

Similar Threads

  1. Client-Side Validation of asp:TextBox with Javascript
    By Matthew Wieder in forum ASP.NET General
    Replies: 3
    Last Post: March 10th, 04:08 PM
  2. Hit Counter in Javascript on client side.
    By aspen19 in forum Macromedia Dynamic HTML
    Replies: 4
    Last Post: August 8th, 01:04 PM
  3. Loading Image on the Server/Client side ?
    By jonesjones webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: October 14th, 05:24 PM
  4. Newbie client side JavaScript debugging issue
    By .NET Developer in forum ASP.NET General
    Replies: 2
    Last Post: August 3rd, 07:36 AM
  5. how can i add client side javascript to a web user control?
    By Tariq Ahmad in forum ASP.NET General
    Replies: 2
    Last Post: July 10th, 11:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139