-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.html
70 lines (66 loc) · 2.57 KB
/
load.html
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
61
62
63
64
65
66
67
68
69
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--[if lt ie 7]> <html class="ie ie6" lang="zh-CN"> <![endif]-->
<!--[if ie 7]> <html class="ie ie7" lang="zh-CN"> <![endif]-->
<!--[if ie 8]> <html class="ie ie8" lang="zh-CN"> <![endif]-->
<!--[if gt ie 8]><!--> <html> <!--<![endif]-->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!--[if lt ie 7]> <title>IE 7 以下版本</title> <![endif]-->
<!--[if ie 7]> <title>IE 7</title> <![endif]-->
<!--[if ie 8]> <title>IE 8</title> <![endif]-->
<!--[if gt ie 8]><title>IE 8 以上版本</title><![endif]-->
<meta name="Generator" content="EditPlus"/>
<meta name="Author" content=""/>
<meta name="Keywords" content=""/>
<meta name="Description" content=""/>
</head>
<body>
<script type="text/javascript">
<!--
var load = function(urls,callback){
var READY_STATE_RE = /^(?:loaded|complete|undefined)$/
var head = document.getElementsByTagName("head")[0] || document.documentElement
var baseElement = head.getElementsByTagName("base")[0];
if(typeof urls == 'string'){
urls = [urls];
}
var len = urls.length;
var loadedNum = 0;
for(var i = 0;i<len;i++){
(function(src){
var script = document.createElement('script');
script.onload = script.onerror = script.onreadystatechange = function() {
if (READY_STATE_RE.test(script.readyState)) {
script.onload = script.onerror = script.onreadystatechange = null
script = null;
if(++loadedNum == len){
callback && callback();
}
}
}
script.src = src;
baseElement ? head.insertBefore(script, baseElement) :head.appendChild(script);
})(urls[i]);
}
}
//console.log(load.toString());
//load('https://raw.github.com/seajs/seajs/master/src/util-request.js',function(){
//alert('load');
//});
function createIframe(code){
var ifram = document.createElement('iframe');
ifram.width = 300;
ifram.height = 100;
document.body.appendChild(ifram);
var doc = ifram.contentDocument || ifram.contentWindow.document;
doc.open();
code = 'var load = '+load.toString()+';load(["http://tonny-zhang.github.io/front-end-code-review/n/j/jquery-1.8.2.js","http://tonny-zhang.github.io/front-end-code-review/n/j/global.js"],function(){document.body.innerHTML="Loaded";'+code+'});';
doc.write('loading...<script>'+code+'</'+'script>');
doc.close();
return ifram;
}
createIframe('alert($);alert(W)');
//-->
</script>
</body>
</html>