Results 1 to 4 of 4

Thread: Need help with getting page name..

  1. #1
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Need help with getting page name..

    Hi all, I've been doing some research on url names. The problem is, I need this code to return like say "index.php", it would return "index". But idk where I went wrong..

    Anyway..

    The code:

    Code:
    <script>
    var sPage;
    var sPath = window.location.pathname;
    //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
    //var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if(sPath.substring(sPath.lastIndexOf('.') + 1)){
    sPage=sPath.split("",3);
    }
    sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    alert(sPage);
    </script>
    ANY help is GREATLY appreciated!

    ~SI~

  2. #2
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Here, this might help explain what I need a bit better. since no 1 seems to want to answer my question....


    http://codingforums.com/showthread.php?t=168020

  3. #3
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    I've just tried your code, in files named showurl.htm and showurl.php, and in both types it returned the full file name, ie showurl.html or showurl.php.

    I tried a couple of the suggestions given by the other forum and with those I just got 'showurl'.

    I tested this using IE7, so I'm not sure if this is a browser issue.

  4. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,832
    Thanks
    49
    Thanked 244 Times in 237 Posts
    Blog Entries
    56

    Default

    Code:
    <script type="text/javascript">
    alert(document.URL.substring(document.URL.lastIndexOf('/')+1,document.URL.length-4));
    </script>
    Arie Molendijk.

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
  •