2010-07-26 98 views

回答

2

你可以在try/catch塊包起來:

function parentIframeResize() { 
    try { 
     var height = getParam('height'); 
     parent.parent.resizeIframe(height); 
    } catch(err) { 
     // do something to recover from the problem, or nothing to suppress it 
    } 
} 
3

嘗試,

if (parent.parent && parent.parent.resizeIframe) { 
    // parent.parent exists and supports resizeIframe 
    parent.parent.resizeIframe(height); 
} 

這應該工作和停止的錯誤。

+3

您可以通過,如果(parent.parent && parent.parent.resizeIframe)在一個表達有一點簡化此。 – thomasrutter 2010-07-26 02:25:36

+0

比try/catch更優雅,尤其是thomasrutter的建議。 +1兩者 – 2010-07-26 05:03:41

相關問題