SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Honolulu, Hawaii
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code generator help

    I'm trying to modify a code generator script that (among other things) inserts images into an HTML document by typing in the image name on a form text area.
    How do I eliminate the absolute path and change this output

    img src="file:///C:/WINDOWS/Desktop/Editor/1.gif" to

    img src="1.gif"?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is quick and dirty, but it might be helpful.
    Code:
    <html>
    <head>
    <script type='text/javascript'>
    
    alert(getFileName("file:///C:/WINDOWS/Desktop/Editor/1.gif"));
    
    function getFileName(path) {
      var a = path.split('/');
      return a[a.length-1];
    }
    </script>
    </head>
    <body>
    </body>
    </html>


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
  •