-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
517 lines (402 loc) · 17.4 KB
/
index.html
File metadata and controls
517 lines (402 loc) · 17.4 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>javascript | 张非飞</title>
<meta name="author" content="张飞">
<meta name="description" content="技术,独立思考,梁鹏,张飞">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:site_name" content="张非飞"/>
<meta property="og:image" content="undefined"/>
<link href="/favicon.png" rel="icon">
<link rel="alternate" href="/atom.xml" title="张非飞" type="application/atom+xml">
<link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel='canonical' href='http://www.liangpeng.net/tags/javascript/' />
</head>
<body>
<header id="header" class="inner"><div class="alignleft">
<h1><a href="/">良朋科技</a></h1>
<h2><a href="/">享受慢生活</a></h2>
</div>
<nav id="main-nav" class="alignright">
<ul>
<li><a href="/archives">文章</a></li>
<li><a href="/dxextfortp">DxExtForTP</a></li>
<li><a href="/team">团队</a></li>
<li><a href="/aboutme">AboutMe</a></li>
<li><a href="/atom.xml">RSS</a></li>
<li> <a title="把这个链接拖到你的Chrome收藏夹工具栏中" href='javascript:(function() {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
var e = document.getElementsByClassName(l);
for (var t = 0; t < e.length; t++) {
document.body.removeChild(e[t])
}
}
function p() {
var e = document.createElement("div");
e.setAttribute("class", a);
document.body.appendChild(e);
setTimeout(function() {
document.body.removeChild(e)
}, 100)
}
function d(e) {
return {
height : e.offsetHeight,
width : e.offsetWidth
}
}
function v(i) {
var s = d(i);
return s.height > e && s.height < n && s.width > t && s.width < r
}
function m(e) {
var t = e;
var n = 0;
while (!!t) {
n += t.offsetTop;
t = t.offsetParent
}
return n
}
function g() {
var e = document.documentElement;
if (!!window.innerWidth) {
return window.innerHeight
} else if (e && !isNaN(e.clientHeight)) {
return e.clientHeight
}
return 0
}
function y() {
if (window.pageYOffset) {
return window.pageYOffset
}
return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
}
function E(e) {
var t = m(e);
return t >= w && t <= b + w
}
function S() {
var e = document.createElement("audio");
e.setAttribute("class", l);
e.src = i;
e.loop = false;
e.addEventListener("canplay", function() {
setTimeout(function() {
x(k)
}, 500);
setTimeout(function() {
N();
p();
for (var e = 0; e < O.length; e++) {
T(O[e])
}
}, 15500)
}, true);
e.addEventListener("ended", function() {
N();
h()
}, true);
e.innerHTML = " <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>";
document.body.appendChild(e);
e.play()
}
function x(e) {
e.className += " " + s + " " + o
}
function T(e) {
e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
}
function N() {
var e = document.getElementsByClassName(s);
var t = new RegExp("\\b" + s + "\\b");
for (var n = 0; n < e.length; ) {
e[n].className = e[n].className.replace(t, "")
}
}
var e = 30;
var t = 30;
var n = 350;
var r = 350;
var i = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3";
var s = "mw-harlem_shake_me";
var o = "im_first";
var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
var a = "mw-strobe_light";
var f = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css";
var l = "mw_added_css";
var b = g();
var w = y();
var C = document.getElementsByTagName("*");
var k = null;
for (var L = 0; L < C.length; L++) {
var A = C[L];
if (v(A)) {
if (E(A)) {
k = A;
break
}
}
}
if (A === null) {
console.warn("Could not find a node of the right size. Please try a different page.");
return
}
c();
S();
var O = [];
for (var L = 0; L < C.length; L++) {
var A = C[L];
if (v(A)) {
O.push(A)
}
}
})() '>High一下</a> </li>
</ul>
<div class="clearfix"></div>
</nav>
<div class="clearfix"></div>
</header>
<div id="content" class="inner">
<div id="main-col" class="alignleft"><div id="wrapper">
<h2 class="archive-title tag">javascript</h2>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2013-08-29T07:12:37.000Z"><a href="/y2013/m08/javascript-run-in-ajax.html">2013-08-29</a></time>
<h1 class="title"><a href="/y2013/m08/javascript-run-in-ajax.html">谨慎使用Ajax动态引入Js(附代码与结果)</a></h1>
</header>
<div class="entry">
<p>代码(index.php):</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre><html><head>
<script src=<span class="string">"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"</span>></script>
<script>console.log(<span class="string">"header"</span>,<span class="keyword">new</span> Date());</script>
</head><body ryt12134=<span class="string">"1"</span>>
<script>console.log(<span class="string">"body_header"</span>,<span class="keyword">new</span> Date());</script>
<script>
(<span class="function"><span class="keyword">function</span><span class="params">($)</span> {</span>
$(<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
console.log(<span class="string">"$$$$"</span> + <span class="keyword">new</span> Date());
});
})(jQuery);
$(document).ready(<span class="function"><span class="keyword">function</span><span class="params">()</span>{</span> console.log(<span class="string">"ready"</span>,<span class="keyword">new</span> Date());});
</script>
<script type=<span class="string">"text/javascript"</span> src=<span class="string">"http://42.121.117.187:8899/test.js?<?php echo time();?>"</span>></script>
<script>console.log(<span class="string">"body_footer"</span>,<span class="keyword">new</span> Date());</script>
</body></html>
</pre></td></tr></table></figure>
<p>代码(index.html):</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre><span class="tag"><<span class="title">html</span>></span><span class="tag"><<span class="title">head</span>></span>
<span class="tag"><<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"</span>></span><span class="javascript"></span><span class="tag"></<span class="title">script</span>></span><span class="tag"></<span class="title">head</span>></span><span class="tag"><<span class="title">body</span> <span class="attribute">ryt12134</span>=<span class="value">"1"</span>></span>
<span class="tag"><<span class="title">script</span>></span><span class="javascript">
$.get(<span class="string">"index.php"</span>,<span class="function"><span class="keyword">function</span><span class="params">(html)</span>{</span>
$(<span class="string">"body"</span>).append(html);
});
</span><span class="tag"></<span class="title">script</span>></span>
<span class="tag"></<span class="title">body</span>></span><span class="tag"></<span class="title">html</span>></span>
</pre></td></tr></table></figure>
<p>测试结果:macos:firefox、chrome、safari -- win8:ie10 基本相同</p>
<ol>
<li>将js文件放在header中,document.ready()会等待js加载完成后再执行(header中的js是优先于body加载的)</li>
<li>将js文件放在body中,则 不考虑js是否加载就会执行(将jquery放在最后面,会导致js出错)</li>
<li><p>直接请求index.php的执行结果</p>
<pre>
header Date {Thu Aug 29 2013 14:32:51 GMT+0800 (CST)}
body_header Date {Thu Aug 29 2013 14:32:51 GMT+0800 (CST)}
qian_test.js Date {Thu Aug 29 2013 14:32:54 GMT+0800 (CST)}
hou_test.js Date {Thu Aug 29 2013 14:32:54 GMT+0800 (CST)}
body_footer Date {Thu Aug 29 2013 14:32:54 GMT+0800 (CST)}
$$$$Thu Aug 29 2013 14:32:54 GMT+0800 (CST)
ready Date {Thu Aug 29 2013 14:32:54 GMT+0800 (CST)}
</pre>
</li>
<li><p>请求index.html的执行结果(显然document.ready优先于js中的代码执行)</p>
<pre>
header Date {Thu Aug 29 2013 14:44:01 GMT+0800 (CST)}
body_header Date {Thu Aug 29 2013 14:44:01 GMT+0800 (CST)}
$$$$Thu Aug 29 2013 14:44:01 GMT+0800 (CST)
ready Date {Thu Aug 29 2013 14:44:01 GMT+0800 (CST)}
body_footer Date {Thu Aug 29 2013 14:44:01 GMT+0800 (CST)}
qian_test.js Date {Thu Aug 29 2013 14:44:04 GMT+0800 (CST)}
hou_test.js Date {Thu Aug 29 2013 14:44:04 GMT+0800 (CST)}
</pre>
</li>
</ol>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="gallery">
<div class="photoset">
<img src="">
</div>
<div class="control">
<div class="prev"></div>
<div class="next"></div>
</div>
</div>
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2010-04-30T10:06:30.000Z"><a href="/y2010/m04/yigejsdeqiguaicuowuzaiunixxizhixing.html">2010-04-30</a></time>
<h1 class="title"><a href="/y2010/m04/yigejsdeqiguaicuowuzaiunixxizhixing.html">一个Js的奇怪错误,在Unix系执行</a></h1>
</header>
<div class="entry">
<p>最近项目总是出现一个js的奇怪错误,在公司的服务器部署,就没有问题,而放到公网,就会出现莫名其妙的错误,比如:break不行等等,按照ie提示的位置去看,代码是没有问题的,firefox下没有问题。</p>
<p>偶然间发现,可能是文件编码的问题,在我机器上eclipse打开,中文乱码,但是这些中文都是被注释掉的,随改变编码,复制,将文件修改为项目相同的编码gbk,粘贴,再部署,居然问题就没了。。</p>
<p>看来在unix+was下,js如果被认为编码不符,也会让ie执行不正常,即便是注释,这个问题很诧异。</p>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<nav id="pagination">
<div class="clearfix"></div>
</nav>
</div></div>
<aside id="sidebar" class="alignright">
<div class="search">
<!--
<form action="//google.com/search" method="get" accept-charset="utf-8">
<input type="search" name="q" results="0" placeholder="搜索">
<input type="hidden" name="q" value="site:www.liangpeng.net">
</form>
-->
<form action="http://www.so.com/s" target="_blank" id="so360form">
<input type="text" x-webkit-speech="" autocomplete="off" name="q" id="so360_keyword" placeholder="搜索">
<input type="hidden" name="ie" value="utf8">
<input type="hidden" name="src" value="zz">
<input type="hidden" name="site" value="liangpeng.net">
<input type="hidden" name="rg" value="1">
</form>
<script type="text/javascript">
(function() {
function $(id) {
return document.getElementById(id);
}
function addEvent(node , type , fn) {
if(node.addEventListener) {
node.addEventListener(type , fn , false);
} else if(node.attachEvent){
node.attachEvent("on" + type , fn);
} else {
node["on" + type] = fn;
}
};
var form = $("so360form");
if(!form) {
return;
}
addEvent(form , "submit" , function() {
form.src.value = "zz_" + window.location.host.replace(/\./g , "_");
return true;
});
})();
</script>
</div>
<div class="widget tag">
<h3 class="title">最新文章</h3>
<ul class="entry">
<li>
<a href="/y2014/m07/project_summary_for_unified_authentication.html">项目总结(统一认证平台)</a>
</li>
<li>
<a href="/y2014/m02/closed_a_door_open_a_window.html">Closed a Door Open a Window</a>
</li>
<li>
<a href="/y2014/m02/no_goal.html">Goal</a>
</li>
<li>
<a href="/y2014/m01/build_trend.html">构筑趋势</a>
</li>
<li>
<a href="/y2014/m01/hearthstone-Teach_you_as_a_person.html">炉石传说 教你作人</a>
</li>
</ul>
</div>
<div class="widget tagcloud">
<h3 class="title">标签云</h3>
<div class="entry">
<a href="/tags/.NET/" style="font-size: 10.00px;">.NET</a><a href="/tags/30岁/" style="font-size: 10.00px;">30岁</a><a href="/tags/404/" style="font-size: 10.00px;">404</a><a href="/tags/4G/" style="font-size: 10.00px;">4G</a><a href="/tags/80后/" style="font-size: 10.00px;">80后</a><a href="/tags/90后/" style="font-size: 10.00px;">90后</a><a href="/tags/9城/" style="font-size: 10.00px;">9城</a><a href="/tags/B股/" style="font-size: 10.00px;">B股</a><a href="/tags/CPI/" style="font-size: 10.00px;">CPI</a><a href="/tags/DBA/" style="font-size: 10.00px;">DBA</a><a href="/tags/ET128/" style="font-size: 10.00px;">ET128</a><a href="/tags/Eclipse/" style="font-size: 10.00px;">Eclipse</a><a href="/tags/GB2312/" style="font-size: 10.00px;">GB2312</a><a href="/tags/GBK/" style="font-size: 10.00px;">GBK</a><a href="/tags/QQ崩溃/" style="font-size: 10.00px;">QQ崩溃</a><a href="/tags/SQL SERVER/" style="font-size: 10.00px;">SQL SERVER</a><a href="/tags/UML/" style="font-size: 10.00px;">UML</a><a href="/tags/UTF-8/" style="font-size: 10.00px;">UTF-8</a><a href="/tags/WOW/" style="font-size: 20.00px;">WOW</a><a href="/tags/a200/" style="font-size: 10.00px;">a200</a><a href="/tags/ajax/" style="font-size: 10.00px;">ajax</a><a href="/tags/android/" style="font-size: 10.00px;">android</a><a href="/tags/apple/" style="font-size: 15.00px;">apple</a><a href="/tags/apt-get/" style="font-size: 10.00px;">apt-get</a><a href="/tags/asterisk/" style="font-size: 10.00px;">asterisk</a><a href="/tags/atom协议/" style="font-size: 10.00px;">atom协议</a><a href="/tags/awesome/" style="font-size: 10.00px;">awesome</a><a href="/tags/bug/" style="font-size: 10.00px;">bug</a><a href="/tags/chrome/" style="font-size: 10.00px;">chrome</a><a href="/tags/cookie/" style="font-size: 10.00px;">cookie</a><a href="/tags/css/" style="font-size: 15.00px;">css</a><a href="/tags/darggable/" style="font-size: 10.00px;">darggable</a><a href="/tags/dialog/" style="font-size: 10.00px;">dialog</a><a href="/tags/div/" style="font-size: 15.00px;">div</a><a href="/tags/dns/" style="font-size: 10.00px;">dns</a><a href="/tags/drupal/" style="font-size: 10.00px;">drupal</a><a href="/tags/editdns/" style="font-size: 10.00px;">editdns</a><a href="/tags/everydns/" style="font-size: 10.00px;">everydns</a><a href="/tags/firefox/" style="font-size: 20.00px;">firefox</a><a href="/tags/flash上传/" style="font-size: 10.00px;">flash上传</a>
</div>
</div>
<div class="widget tag">
<h3 class="title"><a href="http://www.douban.com/people/liangpeng_net" target="_blank">我的豆瓣</a></h3>
<div style="padding:30px">
<script type="text/javascript" src="http://www.douban.com/service/badge/liangpeng_net/?selection=latest&picsize=small&hideself=on&show=collection&n=9&hidelogo=on&cat=drama%7Cmovie%7Cbook%7Cmusic&columns=3"></script>
</div>
</div>
<div class="widget tag">
<h3 class="title">友情链接</h3>
<ul class="entry">
<li><a href="http://www.flive.me" title="赏花赏月赏秋香">花样年华</a></li>
</ul>
</div>
</aside>
<div class="clearfix"></div>
</div>
<footer id="footer" class="inner"><div class="alignleft">
© 2014 张飞
</div>
<div class="clearfix"></div></footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
(function($){
$('.fancybox').fancybox();
})(jQuery);
</script>
</body>
</html>