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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieving name of file that calls script

    Sorry to ask another newbie question. I can do this so easily in PHP but I am a complete beginner with javascript.

    My files teacher_bob.html, teacher_joe.html, teacher_etc.html all call the same javascript.

    Within that javascipt I want to get the name of the calling file.

    So if the script was called from teacher_bob.html I want the "teacher_bob" part read into a variable for later use.

    In PHP I could do something like this:

    Code:
    $teacherName = "./images/" . basename($HTTP_SERVER_VARS["SCRIPT_NAME"], ".html");
    I cannot find an equivelant for javascript. Any help would be greatly appreciated.

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Location
    Brasília, Brazil
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vincentmg
    Any help would be greatly appreciated.
    Use location.pathname:
    PHP Code:
    <script type="text/javascript">
    alert(location.pathname);
    </script> 


  •  

    Posting Permissions

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