IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)

以下代码在IE8下运行通过,在IE9中出错: document.createElement(''); 错误提示: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(" ") : document.createElement("iframe"); oFrame.name = "iframName"; 综合解决办法: var isIE = (document.all) ? true : false;//这里仅仅简单的对是否是IE进行判断,详细浏览器判断:请参考浏览器类型侦测 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"; 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/a497785609/archive/2011/04/12/6317502.aspx </div> <!-- Baidu Button BEGIN --> <div class="bdsharebuttonbox tracking-ad" style="float: right;" data-mod="popu_172"> <a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important"></a> <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间" style="background-position:0 -52px !important"></a> <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"style="background-position:0 -104px !important"></a> <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"style="background-position:0 -260px !important"></a> <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"style="background-position:0 -208px !important"></a> <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"style="background-position:0 -1612px !important" ></a> </div> <script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script> <!-- Baidu Button END --> <link rel="stylesheet" href="http://static.blog.csdn.net/css/blog_detail.css" /> <!--172.16.140.14--> <!-- Baidu Button BEGIN --> <script type="text/javascript" id="bdshare_js" data="type=tools&uid=1536434" ></script> <script type="text/javascript" id="bdshell_js"></script> <script type="text/javascript"> document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000) </script> <!-- Baidu Button END --> <div id="digg" ArticleId="6338254"> <dl id="btnDigg" class="digg digg_disable"> <dt>顶</dt> <dd>0</dd> </dl> <dl id="btnBury" class="digg digg_disable"> <dt>踩</dt> <dd>0</dd> </dl> </div> <ul class="article_next_prev"> <li class="prev_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian']);location.href='/ldl22847/article/details/6331128';">上一篇</span><a href="/ldl22847/article/details/6331128" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian'])">Google Maps API一例错误处理 SCRIPT5007: 无法获取属性“firstChild”的值: 对象为 null 或未定义 main.js </a></li> <li class="next_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian']);location.href='/ldl22847/article/details/6341100';">下一篇</span><a href="/ldl22847/article/details/6341100" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian'])">The operation overflows at compile time in checked mode</a></li> </ul> <div style="clear:both; height:10px;"></div> <div class="similar_article" style="display:none"> <h4>我的同类文章</h4> <div class="similar_c"style="margin:20px 0px 0px 0px"> <div class="similar_c_t"> <label class="similar_cur"> <span style="cursor:pointer" onclick="GetCategoryArticles('623780','ldl22847','foot','6338254');">Asp.Net<em>(148)</em></span> </label> </div> <div class="similar_wrap tracking-ad" data-mod="popu_141" style="max-height:195px;"> <a href="http://blog.csdn.net" style="display:none">http://blog.csdn.net</a> <ul class="similar_list fl"> </ul> <ul class="similar_list fr"> </ul> </div> </div> </div> <script type="text/javascript"> $(function () { GetCategoryArticles('623780', 'ldl22847','foot','6338254'); }); </script> </div> <div id="suggest"></div> <script language="javascript" type='text/javascript'> $(function(){ $.get("/ldl22847/svc/GetSuggestContent/6338254",function(data){ $("#suggest").html(data); }); }); </script> <style> .blog-ass-articl dd { color: #369; width: 99%; /*修改行*/ float: left; overflow: hidden; font: normal normal 12px/23px "SimSun"; height: 23px; margin: 0; padding: 0 0 0 10px; margin-right: 30px; background: url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; } </style> <dl class="blog-ass-articl" id="res-relatived" > <dt><span>猜你在找</span></dt> <div id="adCollege" style="width: 42%;float: left;"> <script src="http://csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script> <script type="text/javascript"> csdn.position.showEdu({ sourceType: "blog", searchType: "detail", searchKey: "6338254", username: "", recordcount: "5", containerId: "adCollege" //容器DIV的id。 }); </script> </div> <div id="res" data-mod="popu_36" class="tracking-ad" style="width: 42%;float: left;margin-right: 30px;"></div> </dl> <script type="text/javascript"> $(function () { setTimeout(function () { var searchtitletags = ' IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)' + ',' + $("#tags").html(); searchService({ index: 'blog', query: searchtitletags, from: 5, size: 5, appendTo: '#res', url: 'recommend', his: 2, client: "blog_cf_enhance", tmpl: '<dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="#{ url }" title="#{ title }" strategy="#{ strategy }">#{ title }</a></dd>' }); }, 500); }); </script> <div id="ad_cen"> <!--AdForward Begin:--> <script type="text/javascript" src="http://csdnim.qtmojo.com/main/s?user=csdn|blog|banner2&db=csdnim&border=0&local=yes&js=ie" charset="gbk"></script> <!--AdForward End--> </div> <div class="comment_class"> <div id="comment_title" class="panel_head"> <span class="see_comment">查看评论</span><a name="comments"></a></div> <div id="comment_list"> </div> <div id="comment_bar"> </div> <div id="comment_form"> </div> <div class="announce"> * 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div> </div> <script type="text/javascript"> var fileName = '6338254'; var commentscount = 0; var islock = false </script> <script type="text/javascript" src="http://static.blog.csdn.net/scripts/comment.js"></script> <div id="ad_bot"> </div> <div id="report_dialog"> </div> <div id="d-top" style="bottom:60px;"> <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;"> <img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复"> </a> <a id="d-top-a" class="btn btn-top backtop" style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])" style=""> <img src="http://static.blog.csdn.net/images/top.png" alt="TOP"> </a> </div> <script type="text/javascript"> $(function () { $("#ad_frm_0").height("90px"); setTimeout(function(){ $("#ad_frm_2").height("200px"); },1000); }); </script> <style type="text/css"> .tag_list { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #D7CBC1; color: #000000; font-size: 12px; line-height: 20px; list-style: none outside none; margin: 10px 2% 0 1%; padding: 1px; } .tag_list h5 { background: none repeat scroll 0 0 #E0DBD3; color: #47381C; font-size: 12px; height: 24px; line-height: 24px; padding: 0 5px; margin: 0; } .tag_list h5 a { color: #47381C; } .classify { margin: 10px 0; padding: 4px 12px 8px; } .classify a { margin-right: 20px; white-space: nowrap; } </style> <div class="tag_list" style="display:none"></div> <script language="javascript" type='text/javascript'> $(function(){ setTimeout(function(){ $.get("/ldl22847/svc/GetTagContent",function(data){ $(".tag_list").html(data).show(); }); }); },500); </script> <div id="pop_win" style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);"> </div> <div id="popup_mask"></div> <style> #popup_mask { position: absolute; width: 100%; height: 100%; background: #000; z-index: 9999; left: 0px; top: 0px; opacity: 0.3; filter: alpha(opacity=30); display: none; } </style> <script type="text/javascript"> $(function(){ setTimeout(function(){ $(".comment_body:contains('回复')").each(function(index,item){ var u=$(this).text().split(':')[0].toString().replace("回复","") var thisComment=$(this); if(u) { $.getJSON("https://passport.csdn.net/get/nick?callback=?", {users: u}, function(a) { if(a!=null&&a.data!=null&&a.data.length>0) { nick=a.data[0].n; if(u!=nick) { thisComment.text(thisComment.text().replace(u,nick)); } } }); } }); },200); setTimeout(function(){ $("a img[src='http://js.tongji.linezing.com/stats.gif']").parent().css({"position":"absolute","left":"50%"}); },300); }); function loginbox(){ var $logpop=$("#pop_win"); $logpop.html('<iframe src="https://passport.csdn.net/account/loginbox?service=http://static.blog.csdn.net/callback.htm" frameborder="0" height="600" width="400" scrolling="no">'); $('#popup_mask').css({ opacity: 0.5, width: $( document ).width() + 'px', height: $( document ).height() + 'px' }); $('#popup_mask').css("display","block"); $logpop.css( { top: ($( window ).height() - $logpop.height())/ 2 + $( window ).scrollTop() + 'px', left:($( window ).width() - $logpop.width())/ 2 } ); setTimeout( function () { $logpop.show(); $logpop.css( { opacity: 1 } ); }, 200 ); $('#popup_mask').unbind("click"); $('#popup_mask').bind("click", function(){ $('#popup_mask').hide(); var $clopop = $("#pop_win"); $("#common_ask_div_sc").css("display","none"); $clopop.css( { opacity: 0 } ); setTimeout( function () { $clopop.hide(); }, 350 ); return false; }); }

你可能感兴趣的:(exception,iframe,浏览器,IE,character,Safari)