![](/img/trans.png)
[英]ReactJS - Refreshing the page always changes URL to index.html
[英]How to find current page url (like “index.html”)?
使用字符串http://www.example.com/section_one/index.html
如何使用RegExp返回index
?
PS:也返回index.html
。
您不需要为此使用正则表达式。 这很简单:
var url = document.URL;
var currentPage= url.split("/").pop();
您可以尝试以下方法。 小提琴
var url = "http://www.example.com/section_one/index.html";
var filename = url.match(/[^\\/]+$/)[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.