Get different JS files at different resolutions

Source: Internet
Author: User
Tags getscript

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.