I'm building a site with js menu that needs to reload the correct page on a browser refresh. How can I make this code that is working simplerCommonly accepted best practices around code organization in JavaScriptHow can I refresh a page with jQuery?Split and parse window.location.hashHow to get window.onunload working for page close, not just page refreshFunction not called after location.reload() or location.reload(true)PhoneGap how to refresh/reload page using one page apphow to make random text change without reloading the pageUpdate hash on scroll and other scroll events - performance issuesHow can one delay javascript function execution after page refresh?How can I get a page to automatically reload within a Google App Script web app (Html page)?

In xXx, is Xander Cage's 10th vehicle a specific reference to another franchise?

How can I describe being temporarily stupid?

Why don't sharp and flat root note chords seem to be present in much guitar music?

How can I override the serving of Media Files? (Implementing authentication for media items)

Count the frequency of items in an array

Gofer work in exchange for Letter of Recommendation

Earliest evidence of objects intended for future archaeologists?

Does C++20 mandate source code being stored in files?

Can others monetize my project with GPLv3?

Why don't politicians push for fossil fuel reduction by pointing out their scarcity?

Find Two largest numbers in a list without using Array

Using は before 欲しい instead が

Vacuum collapse -- why do strong metals implode but glass doesn't?

Is it allowable to use an organization's name to publish a paper in a conference, even after I graduate from it?

Why does AC run even when it is cooler outside than in?

Why doesn't the Falcon-9 first stage use three legs to land?

Could sidesticks be linked?

"Silverware", "Tableware", and "Dishes"

Why doesn't mathematics collapse down, even though humans quite often make mistakes in their proofs?

E: Sub-process /usr/bin/dpkg returned an error code (1) - but how do I find the meaningful error messages in APT's output?

90s(?) book series about two people transported to a parallel medieval world, she joins city watch, he becomes wizard

What is "super" in superphosphate?

How to dismiss intrusive questions from a colleague with whom I don't work?

What is the grammatical function of the word "y" in the following sentence?



I'm building a site with js menu that needs to reload the correct page on a browser refresh. How can I make this code that is working simpler


Commonly accepted best practices around code organization in JavaScriptHow can I refresh a page with jQuery?Split and parse window.location.hashHow to get window.onunload working for page close, not just page refreshFunction not called after location.reload() or location.reload(true)PhoneGap how to refresh/reload page using one page apphow to make random text change without reloading the pageUpdate hash on scroll and other scroll events - performance issuesHow can one delay javascript function execution after page refresh?How can I get a page to automatically reload within a Google App Script web app (Html page)?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm building a site which has some specific needs on the menu. Namely that the menu does not close after you click a link (unless you are on a small screen)
Everything is working but now I want to make sure that the page returns correctly when you refresh the browser.



I've written this script that calls the hash from the url in order to do this, and it works, but the way I have done it means that I have to write a script for every page...



document.addEventListener("DOMContentLoaded", function(event)



 if(window.location.hash == "#production")
load_production();
console.log("The Page has been reloaded!");
else
console.log("The page has a new hit!");

);
document.addEventListener("DOMContentLoaded", function(event)

if(window.location.hash == "#digital")
load_digital();
console.log("The Page has been reloaded!");
else
console.log("The page has a new hit!");

);
document.addEventListener("DOMContentLoaded", function(event)

if(window.location.hash == "#events")
load_events();
console.log("The Page has been reloaded!");
else
console.log("The page has a new hit!");

);


I'm new to js so i just need to understand how i would call the function load_production() by using the window.location hash in one statement










share|improve this question






























    0















    I'm building a site which has some specific needs on the menu. Namely that the menu does not close after you click a link (unless you are on a small screen)
    Everything is working but now I want to make sure that the page returns correctly when you refresh the browser.



    I've written this script that calls the hash from the url in order to do this, and it works, but the way I have done it means that I have to write a script for every page...



    document.addEventListener("DOMContentLoaded", function(event)



     if(window.location.hash == "#production")
    load_production();
    console.log("The Page has been reloaded!");
    else
    console.log("The page has a new hit!");

    );
    document.addEventListener("DOMContentLoaded", function(event)

    if(window.location.hash == "#digital")
    load_digital();
    console.log("The Page has been reloaded!");
    else
    console.log("The page has a new hit!");

    );
    document.addEventListener("DOMContentLoaded", function(event)

    if(window.location.hash == "#events")
    load_events();
    console.log("The Page has been reloaded!");
    else
    console.log("The page has a new hit!");

    );


    I'm new to js so i just need to understand how i would call the function load_production() by using the window.location hash in one statement










    share|improve this question


























      0












      0








      0








      I'm building a site which has some specific needs on the menu. Namely that the menu does not close after you click a link (unless you are on a small screen)
      Everything is working but now I want to make sure that the page returns correctly when you refresh the browser.



      I've written this script that calls the hash from the url in order to do this, and it works, but the way I have done it means that I have to write a script for every page...



      document.addEventListener("DOMContentLoaded", function(event)



       if(window.location.hash == "#production")
      load_production();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );
      document.addEventListener("DOMContentLoaded", function(event)

      if(window.location.hash == "#digital")
      load_digital();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );
      document.addEventListener("DOMContentLoaded", function(event)

      if(window.location.hash == "#events")
      load_events();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );


      I'm new to js so i just need to understand how i would call the function load_production() by using the window.location hash in one statement










      share|improve this question














      I'm building a site which has some specific needs on the menu. Namely that the menu does not close after you click a link (unless you are on a small screen)
      Everything is working but now I want to make sure that the page returns correctly when you refresh the browser.



      I've written this script that calls the hash from the url in order to do this, and it works, but the way I have done it means that I have to write a script for every page...



      document.addEventListener("DOMContentLoaded", function(event)



       if(window.location.hash == "#production")
      load_production();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );
      document.addEventListener("DOMContentLoaded", function(event)

      if(window.location.hash == "#digital")
      load_digital();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );
      document.addEventListener("DOMContentLoaded", function(event)

      if(window.location.hash == "#events")
      load_events();
      console.log("The Page has been reloaded!");
      else
      console.log("The page has a new hit!");

      );


      I'm new to js so i just need to understand how i would call the function load_production() by using the window.location hash in one statement







      javascript menu






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 14:39









      Jaime Paulo LopesJaime Paulo Lopes

      671 silver badge6 bronze badges




      671 silver badge6 bronze badges

























          0






          active

          oldest

          votes










          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%2f55379930%2fim-building-a-site-with-js-menu-that-needs-to-reload-the-correct-page-on-a-brow%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          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%2f55379930%2fim-building-a-site-with-js-menu-that-needs-to-reload-the-correct-page-on-a-brow%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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현