JavaScript.js
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//获取当前的路径
//如果本文件路径为http://localhost:6558/index.html
//返回值为http://localhost:6558
function abspath() {
var abspath = unescape(window.location.href);
// Remove query String
var index = abspath.indexOf("?");
if (index > 0) abspath = abspath.substr(0, index - 1);
index = abspath.lastIndexOf("/");
var index2 = abspath.lastIndexOf("\\");
index = (index > index2) ? index : index2;
if (index <= 0) return abspath;
abspath = abspath.substring(0, index);
if (abspath.substring(0, 1) === "/") abspath = abspath.slice(1);
var re = /file:\/\/\//gi;
if (abspath.match(re) !== null) abspath = abspath.replace(re, ""); // if this is indeed a local file, we strip the "file://" prefix from it.
return (abspath);
}
//SGWorld701对象构造函数
function CreateSGObj() {
try {
var obj = document.getElementById("SGWorld");
if (obj === null) {
obj = document.createElement('object');
obj.setAttribute("name", "SGWorld");
obj.setAttribute("id", "SGWorld");
obj.style.height = "1px";
obj.style.width = "1px";
//定义TerraExplorer对象
obj.setAttribute("classid", "CLSID:3A4F919C-65A8-11D5-85C1-0001023952C1");
document.body.appendChild(obj);
}
console.log(obj);
return obj;
}
catch (e) { alert("CreateSGWorld " + e); }
}
// 获取网页链接中数据,findParam是要查找的对象,defaultValue是默认值
function getParamValue(findParam, defaultValue) {
var arr = document.location.href.split("?");
if (arr.length <= 1) return defaultValue;
arr = arr[1].split("&");
for (var i = 0; i < arr.length; i++) {
if (arr[i].indexOf(findParam) === 0 && arr[i].indexOf("=") === findParam.length) {
arr = arr[i].split("=");
return arr[1];
}
}
return defaultValue;
}