I am using jQuery Mobile to create a web app.I have a problem with the href link and my javascript code.
Here is my javascript code in my index.html and curate.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!
The problem was caused by jQuery Mobile. Here is the detail: http://jquerymobile.com/demos/1.0a4.1/docs/pages/docs-pages.html