Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
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:

JavaScript
<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>
Posted
Updated 12-Jul-16 20:59pm
v2
Comments
Karthik_Mahalingam 13-Jul-16 2:25am    
try using iframe
Member 11449483 15-Jul-16 3:31am    
iframe load next link in his iframe area so scrolling and other page shown only in iframe area.
Karthik_Mahalingam 15-Jul-16 4:12am    
call the script in the very begining of header tag
SRS(The Coder) 13-Jul-16 3:07am    
You can try using a loading panel and hide it once the page completely loaded including header and footer as well, means you can hide it just after loading the header and footer html.
ZurdoDev 13-Jul-16 10:38am    
Are you using a server side language at all?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900