我怎样才能得到在Javascript中的HTML页面的名称? [英] How can i get the name of an html page in Javascript?
本文介绍了我怎样才能得到在Javascript中的HTML页面的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个html页面,我想在html页面
内通过Javascript检索html文档
的名称。这可能吗?
例如。 document =indexOLD.html
解决方案
var path = window.location.pathname;
var page = path.split(/)。pop();
console.log(page);
i have an html page and i would like inside the html page to retrieve the name of the html document via Javascript. Is that possible?
e.g. name of html document = "indexOLD.html"
解决方案
var path = window.location.pathname;
var page = path.split("/").pop();
console.log( page );
这篇关于我怎样才能得到在Javascript中的HTML页面的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文