我正在創建一個項目,我正在構建一個iframe並用html代碼填充以顯示rss提要。下面的代碼顯示了我如何完成此任務。它在Firefox中工作正常,但是當我在Internet Explorer中運行該功能時,它不會加載RSS源。有任何想法嗎?動態構建iframe與調用rss feed的腳本
JavaScript函數
function AddIframe()
{
ifrm = document.createElement("iframe");
ifrm.setAttribute("name", "iFrame1");
ifrm.setAttribute("id","iFrame1");
document.body.appendChild(ifrm);
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write("<html><head><title>testIframe</title></head><body><div> <script language='JavaScript' src='http://itde.vccs.edu/rss2js/feed2js.php?src=http%3A%2F%2Fwww.nfl.com%2Frss%2Frsslanding%3FsearchString%3Dhome&chan=n&num=20&desc=1&date=y&targ=y' type='text/javascript'>" + String.fromCharCode(60).toString() + "/script> </div></body></html>");
ifrm.document.close();
}
HTML
<div>
<input type="button" value="Click Here" onclick="AddIframe();" />
</div>
http://stackoverflow.com/questions/4614850/jquery-add-iframe-with-content – Jaider