2013-01-16 24 views
0

我正在使用以前只能在Internet Explorer中工作的C#/ JavaScript動力系統。我的工作是使其與瀏覽器無關。它使用了一個我正在努力的彈出引擎。獲取絕對父窗口 - 瀏覽器安全

的代碼如下:

function GetBaseIndexDocument() { 
    var doc = window; 
    var i = 0; 
    while (doc.document.getElementById("22411178-0AB6-42AF-8209-FC753F8B58E2") == null && i < 5) { 
     i++; 
     doc = doc.parent; 
    } 
    return doc; 
} 

var _doc = GetBaseIndexDocument(window).document; 
var jQ = _doc.parentWindow.$; 

在Chrome中我得到的代碼的最後一行出現以下錯誤:

Uncaught TypeError: Cannot read property '$' of undefined

而這一次在FireFox:

Error: TypeError: _doc.parentWindow is undefined

我猜測,c的「parentWindow」屬性不存在於這些(可能還有其他幾個)眉毛SERS。我不確定要用什麼替換它。

任何人都可以指向正確的方向嗎?您的幫助將不勝感激。

回答

0

我在網上發現,除了IE 8及更低版本以外,所有瀏覽器都可以使用「defaultView」代替「parentWindow」。