The navigation bar is loading

Here is an example of a problem, however, if you go directly to the navigation page , it loads instantly.

I assume that this is because I create the top base panel in a separate html file and invoking the use of this script.

<script>
    $(function(){
        $("#includeHeader").load("Navigation.html");
    });
</script>

and then immediately after the opening tag tag

<div class="fixed shadow" id="includeHeader"></div>

Is there a better way to invoke an external file, or just copy the navigation code to each HTML page? (seems silly when I want to make changes).

+4
source share
2 answers

Your code is evaluated after loading the entire page. ( http://www.w3schools.com/jquery/jquery_syntax.asp )

, html , - , (, php)

$(function(){ // document-ready event
    // code is executed after the page loads
});

PHP :

<?php  
$header = file_get_contents('/path/to/header.html');
echo $header;
?>
+1

div script $(function(){});, . .

<div class="fixed shadow" id="includeHeader"></div>

<script>
    $("#includeHeader").load("Navigation.html");
</script>

$(function(){}) , . , . Navigation.html, , ?

+1

All Articles