2010-09-07 56 views
1

我需要更改文檔的域,然後再將其設置回原始值。IE8 Javascript文檔。域錯誤

它看起來[域base.site.com的頁面]是這樣的:

function execute() 
{ 
document.domain = "site.com"; 

// Access an object that is on another frame, but did the same set of the domain 

document.domain = "base.site.com"; 

// Access an object that is on this page (window.createPopup()) 
} 

的問題是,能正常工作的IE6(我沒有在7測試)。 但是,當我執行第二個document.domain時,它給了我一個錯誤[Invalid argument]。

有沒有什麼辦法可以「重置」IE8中的文檔域?

+0

我不認爲這是document.domain的多數民衆贊成引發錯誤,但其他地方的函數調用。你沒有測試過其他代碼嗎? – BGerrissen 2010-09-07 10:20:11

+0

我做了一個非常簡單的示例。這是document.domain正在拋出錯誤。如果我刪除其餘的代碼,只留下document.domain,異常仍然發生。 – 2010-09-07 10:24:53

回答

0

使用腳本標籤:

<script type="text/cjs"> 
document.domain = '<your domain host value>'; 
</script>