在 IE9 環境下載入 jquery.bgiframe.js 時,會跳出類似下面的錯誤訊息:
SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5)
jquery.bgiframe.js, 行 8 字符 976
出問題的程式碼大致如下:
{if(!$('iframe.bgiframe',this)[0])this.insertBefore(document.createElement(html),this.firstChild);};
上網查了一下,找到幾種處理方式。
方案一:
this.insertBefore(document.createElement('html'),this.firstChild);
簡單來說,就是在建立元素時,替原本沒加引號的 html 補上一對引號即可解決。目前找到的就是這個做法,日後若有更好的方案再補充。