當我逐句通過這段代碼時,圖中的數值會導致cssLoaded = 0;從我可以看到,長度大於0,並且cssStylesheet.sheet具有屬性,所以應該爲true,因此應將cssLoaded設置爲1,但不會發生。我必須在這裏失去一些東西..?
function _cssIsLoaded(cssStylesheet, stylePath) {
var cssLoaded = 0;
if (tryCount == 3){
console.log('oops');
}
if (cssStylesheet.href == stylePath){
try {
if (cssStylesheet.sheet && cssStylesheet.sheet.cssRules.length > 0){
cssLoaded = 1;}
else if (cssStylesheet.styleSheet && cssStylesheet.styleSheet.cssText.length > 0){
cssLoaded = 1;}
else if (cssStylesheet.innerHTML && cssStylesheet.innerHTML.length > 0){
cssLoaded = 1;}
}
catch(ex){ }
}
if(cssLoaded) {
//alert('cssloadedcomplete');
resetPops();
$('#video-overlay').show();
positionElements();
saveBizzmail();
console.log('try:' + tryCount)
} else {
tryCount+=1;
console.log('try:' + tryCount);
setTimeout(function() { this._cssIsLoaded(cssStylesheet); }, 2000);
}
}
這樣的條件:'if(cssStylesheet.href == stylePath){'pass? – jasonbar
'cssStylesheet.sheet'評估的是什麼? –
@jasonbar哇..喲。就像一匹帶着眼罩的馬! :p做到了! – Damon