Same content on many different Websites












1















I have to create a website and on every page I have a top nav bar. Acctualy I have 10 sites and when I have to change the content of the NavBar, I have to change it in every single site.



What is here best practice?



I have tryed to create a js file with the NavBar inside (document.write"".....), but with this solution I have to convert the html code into JS code and this is not my favorite solution?



Is there an better way?



Thanks for answer.










share|improve this question


















  • 2





    I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

    – Nick Parsons
    Nov 23 '18 at 7:57













  • You've different websites or different pages of the same website?

    – Cristian Traìna
    Nov 23 '18 at 8:22











  • I have different pages on the same website ;-)

    – rayigen85
    Nov 23 '18 at 8:29
















1















I have to create a website and on every page I have a top nav bar. Acctualy I have 10 sites and when I have to change the content of the NavBar, I have to change it in every single site.



What is here best practice?



I have tryed to create a js file with the NavBar inside (document.write"".....), but with this solution I have to convert the html code into JS code and this is not my favorite solution?



Is there an better way?



Thanks for answer.










share|improve this question


















  • 2





    I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

    – Nick Parsons
    Nov 23 '18 at 7:57













  • You've different websites or different pages of the same website?

    – Cristian Traìna
    Nov 23 '18 at 8:22











  • I have different pages on the same website ;-)

    – rayigen85
    Nov 23 '18 at 8:29














1












1








1








I have to create a website and on every page I have a top nav bar. Acctualy I have 10 sites and when I have to change the content of the NavBar, I have to change it in every single site.



What is here best practice?



I have tryed to create a js file with the NavBar inside (document.write"".....), but with this solution I have to convert the html code into JS code and this is not my favorite solution?



Is there an better way?



Thanks for answer.










share|improve this question














I have to create a website and on every page I have a top nav bar. Acctualy I have 10 sites and when I have to change the content of the NavBar, I have to change it in every single site.



What is here best practice?



I have tryed to create a js file with the NavBar inside (document.write"".....), but with this solution I have to convert the html code into JS code and this is not my favorite solution?



Is there an better way?



Thanks for answer.







javascript html






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 7:55









rayigen85rayigen85

62




62








  • 2





    I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

    – Nick Parsons
    Nov 23 '18 at 7:57













  • You've different websites or different pages of the same website?

    – Cristian Traìna
    Nov 23 '18 at 8:22











  • I have different pages on the same website ;-)

    – rayigen85
    Nov 23 '18 at 8:29














  • 2





    I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

    – Nick Parsons
    Nov 23 '18 at 7:57













  • You've different websites or different pages of the same website?

    – Cristian Traìna
    Nov 23 '18 at 8:22











  • I have different pages on the same website ;-)

    – rayigen85
    Nov 23 '18 at 8:29








2




2





I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

– Nick Parsons
Nov 23 '18 at 7:57







I think using php to do this and then using readfile or include is the easiest way to go about doing this. Or you can use the methods founds here if you wish to stick with javascript

– Nick Parsons
Nov 23 '18 at 7:57















You've different websites or different pages of the same website?

– Cristian Traìna
Nov 23 '18 at 8:22





You've different websites or different pages of the same website?

– Cristian Traìna
Nov 23 '18 at 8:22













I have different pages on the same website ;-)

– rayigen85
Nov 23 '18 at 8:29





I have different pages on the same website ;-)

– rayigen85
Nov 23 '18 at 8:29












2 Answers
2






active

oldest

votes


















2














I think you should create a navbar.html file, contain the code of your nav bar, then



    <?php
include 'navbar.html';
?>





share|improve this answer































    0














    First you can use media in css ,




    The @media rule is used in media queries to apply different styles for different media types/devices.




    In my words, you can give different style based on screen's width.



    The Second method is The Browser Object Model.
    BOM, screen.width can return you the width of the current browswer's width.






    share|improve this answer
























    • @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

      – raymondluker
      Nov 23 '18 at 8:27











    • I'm afraid this question is not about applying styles for different screens

      – barbsan
      Nov 23 '18 at 9:01











    • ok. so is this about same nav bar in different URL?

      – raymondluker
      Nov 26 '18 at 9:35












    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442649%2fsame-content-on-many-different-websites%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I think you should create a navbar.html file, contain the code of your nav bar, then



        <?php
    include 'navbar.html';
    ?>





    share|improve this answer




























      2














      I think you should create a navbar.html file, contain the code of your nav bar, then



          <?php
      include 'navbar.html';
      ?>





      share|improve this answer


























        2












        2








        2







        I think you should create a navbar.html file, contain the code of your nav bar, then



            <?php
        include 'navbar.html';
        ?>





        share|improve this answer













        I think you should create a navbar.html file, contain the code of your nav bar, then



            <?php
        include 'navbar.html';
        ?>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 8:19









        Bálint CséfalvayBálint Cséfalvay

        649




        649

























            0














            First you can use media in css ,




            The @media rule is used in media queries to apply different styles for different media types/devices.




            In my words, you can give different style based on screen's width.



            The Second method is The Browser Object Model.
            BOM, screen.width can return you the width of the current browswer's width.






            share|improve this answer
























            • @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

              – raymondluker
              Nov 23 '18 at 8:27











            • I'm afraid this question is not about applying styles for different screens

              – barbsan
              Nov 23 '18 at 9:01











            • ok. so is this about same nav bar in different URL?

              – raymondluker
              Nov 26 '18 at 9:35
















            0














            First you can use media in css ,




            The @media rule is used in media queries to apply different styles for different media types/devices.




            In my words, you can give different style based on screen's width.



            The Second method is The Browser Object Model.
            BOM, screen.width can return you the width of the current browswer's width.






            share|improve this answer
























            • @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

              – raymondluker
              Nov 23 '18 at 8:27











            • I'm afraid this question is not about applying styles for different screens

              – barbsan
              Nov 23 '18 at 9:01











            • ok. so is this about same nav bar in different URL?

              – raymondluker
              Nov 26 '18 at 9:35














            0












            0








            0







            First you can use media in css ,




            The @media rule is used in media queries to apply different styles for different media types/devices.




            In my words, you can give different style based on screen's width.



            The Second method is The Browser Object Model.
            BOM, screen.width can return you the width of the current browswer's width.






            share|improve this answer













            First you can use media in css ,




            The @media rule is used in media queries to apply different styles for different media types/devices.




            In my words, you can give different style based on screen's width.



            The Second method is The Browser Object Model.
            BOM, screen.width can return you the width of the current browswer's width.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 8:26









            raymondlukerraymondluker

            1




            1













            • @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

              – raymondluker
              Nov 23 '18 at 8:27











            • I'm afraid this question is not about applying styles for different screens

              – barbsan
              Nov 23 '18 at 9:01











            • ok. so is this about same nav bar in different URL?

              – raymondluker
              Nov 26 '18 at 9:35



















            • @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

              – raymondluker
              Nov 23 '18 at 8:27











            • I'm afraid this question is not about applying styles for different screens

              – barbsan
              Nov 23 '18 at 9:01











            • ok. so is this about same nav bar in different URL?

              – raymondluker
              Nov 26 '18 at 9:35

















            @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

            – raymondluker
            Nov 23 '18 at 8:27





            @media only screen and (max-width: 600px) { body { background-color: lightblue; } }

            – raymondluker
            Nov 23 '18 at 8:27













            I'm afraid this question is not about applying styles for different screens

            – barbsan
            Nov 23 '18 at 9:01





            I'm afraid this question is not about applying styles for different screens

            – barbsan
            Nov 23 '18 at 9:01













            ok. so is this about same nav bar in different URL?

            – raymondluker
            Nov 26 '18 at 9:35





            ok. so is this about same nav bar in different URL?

            – raymondluker
            Nov 26 '18 at 9:35


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442649%2fsame-content-on-many-different-websites%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()