Get the page file name from the address bar

后端 未结 7 1173
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 15:32

I was wondering if it would be possible to get the page name from the address bar using jquery or javascript. I know this can be done using PHP but don\'t really want to as

7条回答
  •  不思量自难忘°
    2020-12-09 16:07

    Try this

    location.pathname.substring(location.pathname.lastIndexOf("/") + 1);

    location.pathname gives the part(domain not included) of the page url. To get only the filename you have to extaract it using substring method.

提交回复
热议问题