2012-06-07 106 views
2

當我加載與.load()的jQuery的功能的HTML文件,那麼就不會加載整個HTML這樣的:jQuery的.load()不加載HTML正確

取而代之的是:

<html> 
    <head> 
     <link .. /> 
     <script .. /> 
    </head> 
    <body> 
     <div>..</div> 
     <div>..</div> 
    </body> 
</html> 

它加載這樣的:

<link .. /> 

<div>..</div> 
<div>..</div> 

誰能告訴我爲什麼,什麼可以,如果我想L I做完整的HTML?

+0

是否使用XHTML鏈接後? –

+3

RTFM:D--這不是jQuery,它將這些元素視爲瀏覽器 - [.load()](http://api.jquery.com/load/) - 在這個過程中,瀏覽器通常會過濾來自文檔的元素,例如,或<head>元素。因此,由.load()檢索的元素可能不完全相同,就好像文檔被瀏覽器直接檢索一樣。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/402037/">Andreas</a></span> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">如果您嘗試拉入'html','head'和'body '元素通過AJAX進入DOM,你做錯了。 – <span class="text-secondary"> <small> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">-1<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>你</p> <ol> <li>文檔準備狀態中首先加載了jQuery的頭部</li> <li>裝載</li> <li>你檢查的div名稱,以確保您使用Firefox右</li> <li>使用螢火因爲它會告訴你什麼是返回或錯誤</li> <li>使用負載需要html的地方</li> </ol> <p>你的頭,你的代碼已經jQuery的應該是這樣的</p> <pre><code class="prettyprint-override">$(document).ready(function() { $('#mydivforcontent').load("theforeignpage"); // you may need to replace load with html }); </code></pre> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/10927370">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2012-06-07 07:22:19</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/692779/">Jim</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> <!-- comments --> <div class="comments"> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">你真的沒有真正回答這個問題。 – <span class="text-secondary"> <small> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">記住,使用AJAX加載不會加載頭部,而只會加載主體(或頁面的特定方面) – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/692779/">Jim</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-ukvacpsi-nn.html" target="_blank" title="JQuery .load()不能正確加載"> JQuery .load()不能正確加載 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-blmzcgro-br.html" target="_blank" title="JQuery .load()不會加載html"> JQuery .load()不會加載html </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-spuppzqt-bna.html" target="_blank" title="JQuery .Load HTML格式不正確"> JQuery .Load HTML格式不正確 </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-aqqzunot-eg.html" target="_blank" title="LOAD DATA LOCAL INFILE不加載正確"> LOAD DATA LOCAL INFILE不加載正確 </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-fqfvncyk-oe.html" target="_blank" title="jQuery的.load()使用.load功能不加載HTML註釋標記"> jQuery的.load()使用.load功能不加載HTML註釋標記 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-qwiuasgk-bbe.html" target="_blank" title="Html加載不正確"> Html加載不正確 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-hgkfbxar-bdw.html" target="_blank" title="jQuery .load()不加載插件"> jQuery .load()不加載插件 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-mcjvgqff-bca.html" target="_blank" title="JQuery .load()不加載類"> JQuery .load()不加載類 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-ycpjwvjn-baa.html" target="_blank" title="訪問HTML元素加載與jQuery .load()"> 訪問HTML元素加載與jQuery .load() </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-yrltfdfs-beq.html" target="_blank" title="jquery .load()社交按鈕正在加載"> jquery .load()社交按鈕正在加載 </a> </li> <div> <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-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-zdijnfip-bmz.html" target="_blank" title="從jquery .load()加載JavaScript的HTML頁面加載()"> 從jquery .load()加載JavaScript的HTML頁面加載() </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-wfsaqjpo-bkr.html" target="_blank" title="jquery函數load()無法正確加載dojo內容"> jquery函數load()無法正確加載dojo內容 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-vmmrmmfu-oa.html" target="_blank" title="使用jQuery .load和內容將無法正確加載"> 使用jQuery .load和內容將無法正確加載 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-nyfgpxxk-mk.html" target="_blank" title="的Jquery和HTML存儲不加正確"> 的Jquery和HTML存儲不加正確 </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-tjgiryeo-ce.html" target="_blank" title="jQuery .load不會加載可可WebView中的本地html文件"> jQuery .load不會加載可可WebView中的本地html文件 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-ksryljat-bnh.html" target="_blank" title="jQuery的.load不加載數據"> jQuery的.load不加載數據 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-fvxnibnh-bq.html" target="_blank" title="jQuery的.load()不能加載JS"> jQuery的.load()不能加載JS </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-pszfvswm-hv.html" target="_blank" title="jQuery .load()不會加載我的腳本"> jQuery .load()不會加載我的腳本 </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-bkqfgvwb-baw.html" target="_blank" title="jQuery的.load/.empty不加載和DIV"> jQuery的.load/.empty不加載和DIV </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-toosjntg-c.html" target="_blank" title="Jquery的加載沒有正確加載"> Jquery的加載沒有正確加載 </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-eislktrc-so.html" target="_blank" title="圖像加載不正確在HTML中"> 圖像加載不正確在HTML中 </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-hdnzdijb-bcx.html" target="_blank" title="Colorbox內嵌HTML加載不正確"> Colorbox內嵌HTML加載不正確 </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-dxvvfwpm-baz.html" target="_blank" title="HTML 5視頻IE9加載不正確"> HTML 5視頻IE9加載不正確 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-cmdkxoep-nm.html" target="_blank" title="html javascript代碼加載不正確"> html javascript代碼加載不正確 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-gmuqhlgm-da.html" target="_blank" title="jQuery腳本與.load遠程加載HTML不工作時"> jQuery腳本與.load遠程加載HTML不工作時 </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-vbowdzba-eq.html" target="_blank" title="Claim.py高清load()方法加載不正確"> Claim.py高清load()方法加載不正確 </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-cfykdhpw-dz.html" target="_blank" title="jQuery .load不加載swfobject內容"> jQuery .load不加載swfobject內容 </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-uhylipzw-bdt.html" target="_blank" title="Jquery .load不加載JavaScript或閃存"> Jquery .load不加載JavaScript或閃存 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-xnyfyofc-t.html" target="_blank" title="JavaScript/jQuery自動加載不正確"> JavaScript/jQuery自動加載不正確 </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-balkkmrv-bnc.html" target="_blank" title="Jquery腳本加載不正確"> Jquery腳本加載不正確 </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-yujjhsmr-bho.html" target="_blank" title="當啓動vscode我的SO非常慢"> 當啓動vscode我的SO非常慢 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-sudteplq-bkk.html" target="_blank" title="BotAuth與Azure表存儲錯誤"> BotAuth與Azure表存儲錯誤 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-mjalosly-bkx.html" target="_blank" title="試圖在MAP中運行函數"> 試圖在MAP中運行函數 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-dmmrnbnm-zv.html" target="_blank" title="指定具有絕對路徑的庫的GCC行爲是什麼"> 指定具有絕對路徑的庫的GCC行爲是什麼 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-ntugclqv-bak.html" target="_blank" title="奇怪填充用的UIButton"> 奇怪填充用的UIButton </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-gmkdydeq-bcq.html" target="_blank" title="Kafka Streams:使用相同的`application.id`來消費多個主題"> Kafka Streams:使用相同的`application.id`來消費多個主題 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-ontdxdfj-bca.html" target="_blank" title="同時具有自定義功能和任務窗格"> 同時具有自定義功能和任務窗格 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-pywewtew-bbu.html" target="_blank" title="Squarespace:在移動設備上只"> Squarespace:在移動設備上只 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-ewkeymbx-bbo.html" target="_blank" title="Xamarin Android RelativeLayout設計器設置"> Xamarin Android RelativeLayout設計器設置 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-knahlihj-bbd.html" target="_blank" title="製作一個黑暗的崩潰的導航欄視覺上不同"> 製作一個黑暗的崩潰的導航欄視覺上不同 </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-ukvacpsi-nn.html" target="_blank" title="JQuery .load()不能正確加載"> JQuery .load()不能正確加載 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-blmzcgro-br.html" target="_blank" title="JQuery .load()不會加載html"> JQuery .load()不會加載html </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-spuppzqt-bna.html" target="_blank" title="JQuery .Load HTML格式不正確"> JQuery .Load HTML格式不正確 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-aqqzunot-eg.html" target="_blank" title="LOAD DATA LOCAL INFILE不加載正確"> LOAD DATA LOCAL INFILE不加載正確 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-fqfvncyk-oe.html" target="_blank" title="jQuery的.load()使用.load功能不加載HTML註釋標記"> jQuery的.load()使用.load功能不加載HTML註釋標記 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-qwiuasgk-bbe.html" target="_blank" title="Html加載不正確"> Html加載不正確 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-hgkfbxar-bdw.html" target="_blank" title="jQuery .load()不加載插件"> jQuery .load()不加載插件 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-mcjvgqff-bca.html" target="_blank" title="JQuery .load()不加載類"> JQuery .load()不加載類 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-ycpjwvjn-baa.html" target="_blank" title="訪問HTML元素加載與jQuery .load()"> 訪問HTML元素加載與jQuery .load() </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-yrltfdfs-beq.html" target="_blank" title="jquery .load()社交按鈕正在加載"> jquery .load()社交按鈕正在加載 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>