Image name only

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mehdi

    Image name only

    Hi,

    Is there any way that I could get the image name only from
    document.getEle mentById('Image 1').src without using any character function
    to filter the returned string?
    This returns "http://localhost/mywebsite/sampleimage.jpg " but I only need
    to get "sampleimage.jp g".



    Thanks for your time


    Kind regards

    Mehdi


  • Murray

    #2
    Re: Image name only


    "Mehdi" <nospam@nospam. nospam> wrote in message
    news:CE6nc.5595 $e11.52922384@n ews-text.cableinet. net...[color=blue]
    > Hi,
    >
    > Is there any way that I could get the image name only from
    > document.getEle mentById('Image 1').src without using any character function
    > to filter the returned string?
    > This returns "http://localhost/mywebsite/sampleimage.jpg " but I only need
    > to get "sampleimage.jp g".
    >
    >
    >
    > Thanks for your time
    >
    >
    > Kind regards
    >
    > Mehdi[/color]

    Internet Explorer 6 has an additional property on IMG called nameProp which
    will do what you want. But if you want to support other browsers try:

    var src = document.getEle mentById('Image 1').src;
    var fileName = src.substring(s rc.lastIndexOf( '/') + 1);


    Comment

    • Mehdi

      #3
      Re: Image name only

      Thanks Murray, you solved my problem.


      Regards


      Mehdi


      Comment

      Working...