日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)

發(fā)布時(shí)間:2023/11/27 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IE9 : DOM Exception: INVALID_CHARACTER_ERR (5) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

以下代碼在IE8下運(yùn)行通過,在IE9中出錯(cuò):
document.createElement('<iframe id="yui-history-iframe" src="../../images/defaults/transparent-pixel.gif" style="position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden;"></iframe>');
錯(cuò)誤提示:exception : SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5)


思路分析:
第一步:兼容IE9,firefox,Opera,Safari等瀏覽器;
var iframe = document.createElement("iframe");
iframe.setAttribute("id", "yui-history-iframe");
iframe.setAttribute("src", "../../images/defaults/transparent-pixel.gif");
iframe.setAttribute("style","position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden;");

第二步:兼容IE6-8:由于ie6-8 不能修改iframe的name屬性
var oFrame = isIE ? document.createElement("<iframe name=/"" + this._FrameName + "/">") : document.createElement("iframe");
oFrame.name = "iframName";


綜合解決辦法:

??????? var isIE = (document.all) ? true : false;//這里僅僅簡單的對是否是IE進(jìn)行判斷,詳細(xì)瀏覽器判斷:請參考瀏覽器類型偵測
??????? var ua = navigator.userAgent.toLowerCase().match(/msie ([/d.]+)/)[1];
??????? if (ua == "9.0") {
??????????? isIE = false;
??????? }
var oFrame = isIE ? document.createElement("<iframe name=/"" + this._FrameName + "/">") : document.createElement("iframe");
oFrame.name = "iframName";

?

轉(zhuǎn)載于:https://www.cnblogs.com/zhangqs008/archive/2011/04/12/2341141.html

總結(jié)

以上是生活随笔為你收集整理的IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。