[英]How to run jquery script if page is index.html
How to run jquery script if page is index.html. 如果页面是index.html,如何运行jquery脚本。 When I entered URL in browser like http://qubedns.co.in/ is will automatically execute but not show the home page name (default).
当我在浏览器(如http://qubedns.co.in/ )中输入URL时,它将自动执行,但不显示主页名称(默认)。 Not show like http://qubedns.co.in/index.html
不显示为http://qubedns.co.in/index.html
I want the current page name when user hit the url http://qubedns.co.in/ to run some script. 当用户点击url http://qubedns.co.in/来运行某些脚本时,我想要当前的页面名称。 If I get the page name 'index/html' I will finish it.
如果获得页面名称“ index / html”,则将其完成。
I used for other page 我用于其他页面
var currPageView = document.location.pathname.match(/[^\/]+$/)[0];
if(currPageView == 'index.html')
{
// My Script here
}
I have try with: 我尝试过:
var currPageView;
if($(location).attr('href')=='http://qubedns.co.in'){
currPageView == window.location.host + '/' + 'index.html';
}else{
currPageView = document.location.pathname.match(/[^\/]+$/)[0];
}
Is it right? 这样对吗? any others solution ?
还有其他解决方案吗?
if your trying like this then you will get total url 如果您这样尝试,那么您将获得总网址
$(location).attr('href');
can you try like this ...and check this link also 你可以这样尝试...并检查此链接吗
http://en.proft.me/2014/08/1/how-work-location-url-javascript-jquery-angularjs/ http://en.proft.me/2014/08/1/how-work-location-url-javascript-jquery-angularjs/
var currPageView;
if($(location).attr('hostname')=='http://qubedns.co.in'){
currPageView == window.location.hostname + '/' + 'index.html';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.