2012-04-04 35 views

回答

0

要與各種各樣的瀏覽器兼容,你需要的東西,如:

if (typeof arguments.caller == 'function') { 
    return arguments.caller; 

} else if (typeof arguments.callee == 'function' && 
      typeof arguments.callee.caller == 'function') { 
    return arguments.callee.caller; 

} else { 
    // called from global scope, in strict mode or browser doesn't support 
    // either of the above access methods 
} 

注意,在訪問arguments.callee的或主叫方將扔在ES5嚴格模式例外,上述可避免,但我現在無法測試它。

相關問題