How can we reload html page without blinking?

Why is a function in Javacript not called when loading new page by clicking href url?

  • I have a problem with the href link and my javascript code. Here is my javascript code in my ∈dex.html∈dex.htmlindex.html and curate.htmlcurate.htmlcurate.html: $(document).ready(function(){ alert("Hello!"); }); In the html code, it's just code of a navigation bar: <ul> <li><a href="index.html">Home</a></li> <li><a href="curate.html">curate</a></li> </ul> So the problem is: when I on the home page, for instance, click the curate link to the curate page, the alert will not pop out. It seems the function is not called in javascript. However, it works if I reload the curate page. Same problem from the curate page to the home page. The problem will be fixed if I change the html code as <ul> <li><a href="index.html" >Home</a></li> <li><a onclick="gotoCurate()">curate</a></li> </ul> and add the js code in index.html: function gotoCurate() { window.location="curate.html" } Similar to the curate page. I guess maybe when using href, the page isn't really load. I add `<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">` in the head but it doesn't work. For some reasons I would like to use href to direct between the pages. So does anyone know how can i fix the problem while keeping the href links? Thanks!

  • Answer:

    An anchor tag without a href attribute is not safe. First, without an href attribute, it will not be a link. If it isn't a link, it won't be a keyword. Second, you should have an alternative for when the JavaScript doesn't run. Take a look at this http://jsfiddle.net/wCLAx/6/. You might be wrong. I just tested this with chrome. Both of them work fine except for the unsafe condition where the href attribute is not defined in one of the cases.

Boopathi Rajaa at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.