Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script Working Directory

    Let's say I have an HTML page in the root directory "/".
    Now, in the folder (root)/scripts, I have a .js file which is included in the HTML file.
    In the JavaScript code I am settin a new source URL for an image in the HTML page. The image is located inside the folder (root)/images.

    So, for calling the image from the HTML file I would do this: src="./images/image.ext". But from what is the directory path I should use from the JS file? imageObject.src = 'what path?'

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,466
    Thanks
    3
    Thanked 495 Times in 482 Posts
    the javascript should be considered as part of the page and therefore at the same directory path and level
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try

    ../images/pic01.jpg
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vwphillips
    the javascript should be considered as part of the page and therefore at the same directory path and level
    You were right. Thanks you very much.


  •  

    Posting Permissions

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