Gets the directory of the current Web site
JS Get site Root path (site and virtual directory), get root address of website or virtual directory, function Getrootpath () {//whole domain name (such as: http://vc3.cn/index.php/Home/Index/ Store) var strfullpath=window.document.location.href; The latter segment (for example: Index.php/home/index/store) var strpath=window.document.location.pathname;//gets the position var pos= Strfullpath.indexof (strpath);//Get the domain name (e.g. http://vc3.cn) var prepath=strfullpath.substring (0,pos); var postpath=strpath.substring (0,STRPATH.SUBSTR (1). IndexOf ('/') +1); return (Prepath+postpath);}
// JS Gets the root path (site and virtual directory) of the Web site, obtaining the root address of the Web site or virtual directory function Getrootpath () { var pathName = window.location.pathname.substring (1); var webName = PathName = = "? ": pathname.substring (0, Pathname.indexof ('/')); // return Window.location.protocol + '//' + Window.location.host + '/' + webName + '/'; return Window.location.protocol + '//' + Window.location.host + '/' + webName;
The wording of jquery
<script type= "Text/javascript" > var strfullpath=window.location.href; var strpath=window.location.pathname; var pos=Strfullpath.indexof (strpath); var prepath=strfullpath.substring (0, POS); if ($ (window). Width () >789) { $.getscript (prepath+ "/public/home/js/jquery.flexslider.js", function() {}); } </script>
Determine if the browser is a phone or a PC
<script type= "Text/javascript" > var type = Navigator.userAgent.match (/.*mobile.*/)? " Mobile ":" PC "; if (type== "PC") { $.getscript ("http://vc3.cn/Public/home/js/jquery.flexslider.js",function (){ }); } </script>
Get different JS files at different resolutions