我在HTML页面的<head>
部分找到此代码(collegue使这个,但他不在这里工作了):理解晦涩的JavaScript代码
(function(window, PhotoSwipe){
document.addEventListener('DOMContentLoaded', function(){
var options = {},
instance = PhotoSwipe.attach(window.document.querySelectorAll('#Gallery a'), options);
}, false);
}(window, window.Code.PhotoSwipe));
我能够理解中央部分(从document.addEventListener),我无法理解第一行和最后一行。他们在这里做什么?该代码来自名为PhotoSwipe的开源图像库。任何指针赞赏。
[编辑]
这段代码一样:
document.addEventListener('DOMContentLoaded', function(){
var options = {},
instance = window.Code.PhotoSwipe.attach(window.document.querySelectorAll('#Gallery a'), options);
}, false);
?
我发现这是您可以使用该库下载示例的确切副本。 – Battery 2012-04-18 14:59:33