Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Javascript Question

  • 21-08-2002 6:24pm
    #1
    Registered Users, Registered Users 2 Posts: 55,571 ✭✭✭✭


    Hi all,

    I need to get a particular part of a URL using javascript.
    For example, take the following URL:

    http://www.domainxyz.com/dir1/dir2/index.aspx?mode=edit&token=1x7g4sa032

    What I need is the "index" part of the URL (i.e. the filename, minus the URL before it, or the extension (.aspx), or the parameters).

    Do I need to get document.location and hack it with string functions? Or is there a better way?

    - Dave.


Comments

  • Registered Users, Registered Users 2 Posts: 3,889 ✭✭✭cgarvey


    Originally posted by TmB

    Do I need to get document.location and hack it with string functions? Or is there a better way?

    Yeah thats the way I use anyway. You can narrow down what to search on by using document.locaiton.pathname...

    var ext = document.location.pathname.substring( document.location.pathname.lastIndexOf( "." ) );
    var base = document.location.pathname.substring( document.location.pathname.lastIndexOf( "/" ) + 1, document.location.pathname.lastIndexOf( "." ) );


  • Registered Users, Registered Users 2 Posts: 55,571 ✭✭✭✭Mr E


    Perfect!

    Thanks a million..... I'll give that a go this morning.

    - Dave.


Advertisement