SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I get the filename of the page that a script is running in?

    If I have a piece of JavaScript that is inside of an file called index.html how can I dynamically retrieve the name of the file (index.html)?

    I've experimented with document.location and such, but the problem with that is that if the user visits http://www.domain.com/ instead of http://www.domain.com/index.html then document.location wont return the index.html portion.

    Is it even possible for JS to access the filename that it exists inside of?

    Thanks!

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it can only tell what the URL used to access the page was.

    Can't you just write it so that if no file or sub-folder is selected it will be the same as index.html?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •