- //判断是本地(localhost)还是线上(.com)返回url
- function getURL() {
- var strPath = window.document.location.pathname;
- var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);// 取得文件根目录
- var arr = ["com","xyz","net","top","tech","org","gov","edu","cn","tv"];
- var url = 'http://'+document.domain;
- for (var i = 0; i < arr.length; i++) {
- if (url.indexOf(arr[i])>-1){
- return url;
- } else {
- return (url + postPath);
- }
- }
- }
复制代码
|
|