mirror of
https://github.com/JamesonHuang/OpenWrt_Luci_Lua.git
synced 2024-11-23 22:00:11 +00:00
61 lines
1.5 KiB
HTML
61 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
</head>
|
|
<body>
|
|
<script>
|
|
var outerPagePtr;
|
|
var outerPageOrigin;
|
|
var ALLOWORIGIN = "http://miwifi.com";
|
|
var EventUtil = {
|
|
addHandler: function (element, type, handler) {
|
|
if (element.addEventListener) {
|
|
element.addEventListener(type, handler, false);
|
|
} else if (element.attachEvent) {
|
|
element.attachEvent("on" + type, handler);
|
|
} else {
|
|
element["on" + type] = handler;
|
|
}
|
|
}
|
|
};
|
|
|
|
EventUtil.addHandler(window, "message", function (event) {
|
|
var url = event.data;
|
|
outerPagePtr = event.source;
|
|
outerPageOrigin = event.origin;
|
|
if (outerPageOrigin == ALLOWORIGIN) {
|
|
processMessage(url, function(rsp){
|
|
outerPagePtr.postMessage(rsp, outerPageOrigin);
|
|
});
|
|
}
|
|
});
|
|
|
|
var processMessage = function(url, callback){
|
|
var httpRequest = null;
|
|
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
|
|
httpRequest = new XMLHttpRequest();
|
|
} else if (window.ActiveXObject) { // IE
|
|
try {
|
|
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
|
|
}catch (e) {
|
|
try {
|
|
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
|
|
}catch (e) {}
|
|
}
|
|
}
|
|
if (httpRequest != null){
|
|
httpRequest.onreadystatechange = function(){
|
|
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
|
|
callback(httpRequest.responseText);
|
|
}
|
|
};
|
|
httpRequest.open("GET", url, true);
|
|
httpRequest.send();
|
|
}else{
|
|
callback('{code:-1, msg:"Giving up :( Cannot create an XMLHTTP instance"}');
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |