我正在使用 Firebug 1.7.3 对 Firefox 3.6.21 中的站点进行一些调试。当页面首次加载时,我尝试执行的 Javascript 根本不会加载。我打开 Firebug 看看问题出在哪里,我点击重新加载,突然它开始工作了。
我不知道这里发生了什么。
function initStations() {
//console.log("in stations")
ringContainer = $("#ringContainer");
ringWidth = ringHeight = ringContainer.innerWidth();
//console.log(ringWidth + " " + ringHeight);
originX = (ringWidth / 2) - 0;
originY = (ringHeight / 2);
radius = originY + 20;
//console.log(originX + " " + originY + " " + radius);
// get the ul containing the stations
stationList = $("#stationList");
// an array of the li elements
stationLiElems = $("#stationList li");
// how many stations
length = stationLiElems.size();
// distance between stations in degrees
spacing = (360 / length)
// 360 degrees in circle divided by the number of stations
// array of stations
stations = [];
// debug
//console.log(stationList);
stationLiElems.each(function(index, element) {
//console.log(index +" - "+ spacing);
stations[index] = {
'element' : element,
// http://stackoverflow.com/questions/925118/algorithm-for-finding-out-pixel-coordinates-on-a-circumference-of-a-circle
'x' : originX + radius * Math.sin(spacing * index * 0.0174532925 ),
'y' : originY + radius * Math.cos(spacing * index * 0.0174532925 )
}
$(element).css({'top' : stations[index].y , 'left' : stations[index].x });
});