2013-01-08 67 views
0

我需要一個解決方案來刷新適用於不同瀏覽器的iframe。
你能證實,我在互聯網上找到的代碼是正確的或給我正確的JavaScript?Javascript:刷新IFrame瀏覽器特定

IE 7 window.document.getElementById('iframeId').contentWindow.location.reload(true);

IE 8 window.document.getElementById('iframeId').contentWindow.location.reload(true);

IE 9 window.document.getElementById('iframeId').contentWindow.location.reload(true);

火狐12-17
window.document.getElementById('iframeId').src = window.document.getElementById('iframeId').src;

document.getElementById('iframeId').contentWindow.location.reload();

Chrome現在
???

Safari和Opera會很好,但以上都很重要。 iframe可能位於不同的域中。

非常感謝提前!

+0

喜做這項工作的IE版本?我嘗試按照此處所述使用,但無法重新加載iFrame。 – Coder

回答

0

在Chrome版本23.0.1271.97我只是用

document.getElementById('iframeId').contentWindow.location.reload()

試着和它的作品。 你可以嘗試:

document.getElementById('iframeId').contentWindow.location.href = document.getElementById('iframeId').contentWindow.location.href