Master page in HTML

1

Good morning! I'm trying to make a Master Page in HTML 5. I created an HTML page called master.html with every menu structure I want. I call this page as follows on my index.php page and it works:

<html>
    <body>        
        <div id="new-header">
            <script>
                $("#new-header").load("page/master.html");
            </script>
        </div>

        <div>Index</div>     

    </body>
</html>

When I call this same structure on another page, profile.html for example, the master structure does not work! What am I doing wrong?

    
asked by anonymous 24.08.2015 / 15:17

2 answers

2

Your error occurs because of the lack of the Jquery reference.

Just include the reference that can be made via Cdn,

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

ordownloadthatcanbefound here .

See this example I made.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <div id="new-header">

    </div>

    <div>Index</div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><script>$("#new-header").load("page/master.html");
    </script>
</body>
</html>
    
24.08.2015 / 16:05
2

All pages that you insert the "page / master.html" insertion code should contain Jquery. Put the following code inside the head tag:

<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>

Ordownloadjqueryandchangesrctoyourlocation.

Ifyoudonotwanttoputthecodeoneverypageyouareinserting,youcanchangeyour"page / master.html" insertion script into an include in php:

<?php include("page/master.html") ?>

Or an iframe in html:

<iframe src="page/master.html"></iframe>
    
27.08.2015 / 21:57