Results 1 to 4 of 4

Thread: I have a script that has this on the same page

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default I have a script that has this on the same page

    Code:
    <script language="javascript" type="text/javascript">
    function root_path() {return('../../');}
    </script>
    Can someone explain what this is and how it works.

    Thanks,

    Bud
    Thanks,

    Bud

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    All this function does is return a string.

    For example:
    Code:
    alert(root_path()+"styles/images");
    Would alert: ../../styles/images.

    This should really be kept in a variable like so:
    Code:
    var root_path = "../../";
    And then you would have to go around changing all the places that it uses it as a function.

    The function was probably made so that the programmer could access the root path (the root directory) faster without having to type ../../ everytime.
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    Is is a different way of using base href?
    Code:
    <head>
    <base href="http://www.w3schools.com/images/" target="_blank" />
    </head>
    Thanks,

    Bud

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't think there is.

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
  •