0

我正在努力学习url持久化,有朋友告诉我研究这段代码:

$(document).ready(function(){
var objects = {};
var DEFAULT_LOCATION = "diameter";


$("#animateObjects").hide();


var urlDimension = location.hash.replace("#","");
if (urlDimension.length == 0) {
    // location.hash = "#" + DEFAULT_LOCATION;
    urlDimension = DEFAULT_LOCATION;
    $("#"+DEFAULT_LOCATION).addClass("active");
    clog("started with no dimension, defaulted to " + DEFAULT_LOCATION);
}
else {
    $("#"+urlDimension).toggleClass("active");
    clog("started with dimension: " + urlDimension);
}

clog() 方法完成了什么?

完整代码在这里

4

1 回答 1

1

我敢打赌它是一个包装器,console.log以满足 IE 无法处理的问题。

像这样的东西:

function clog(message) {
    try {
        console.log('message');
    } 
    catch (ex) {}
}

参考:http ://benwong.me/javascript-console-log-and-internet-explorer/

于 2012-07-31T01:06:04.250 回答