在整页加载后,使用jquery包括HTML页面加载中的外部文件 [英] Using jquery include external file in HTML page load after full page load
本文介绍了在整页加载后,使用jquery包括HTML页面加载中的外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Jquery包含外部页眉,页脚文件但是在整页加载后加载。这不是很好的用户体验,所以我需要使用页面HTML加载外部文件。
我尝试了什么:
I am using Jquery for include external header , footer file but it load after full page load . it is not good user experience so i need to load external files with the page HTML.
What I have tried:
<script>
$(document).insertBefore(function () {
$("#Header").load("common/ChHeader.htm");
$("#Footer").load("common/ChFooter.htm");
});
</script>
<script>
$(document).ready(function () {
$("#Header").load("common/ChHeader.htm");
$("#Footer").load("common/ChFooter.htm");
});
</script>
<script>
window.onload = function () {
$("#Header").load("common/ChHeader.htm");
$("#Footer").load("common/ChFooter.htm");
};
</script>
推荐答案
( document ) .insertBefore( function (){
(document).insertBefore(function () {
( #Header)。load( common / ChHeader.htm );
("#Header").load("common/ChHeader.htm");
( #Footer ).load( common / ChFooter.htm);
});
< / script>
< script>
("#Footer").load("common/ChFooter.htm"); }); </script> <script>
这篇关于在整页加载后,使用jquery包括HTML页面加载中的外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文