Refresh html loaded on div using jQuery? -
i making website , use jquery load html pages inside divs, main index html remains intact way. problem if user browsing html loads inside div , tries refresh browser(f5) content gets "lost" since it's 1 page(index.html).
is there way around this?
<a onclick='$("#content").load("page1.html");'>page1</a> <div id="content"></div>
there's 2 solutions that. if user clicks link, add hashtag url. example:
<a onclick='$("#content").load("page1.html"); window.location.hash = "page1.html";'>page1</a> then, in jquery, check hashtag when user visits site:
$(function() { if (window.location.hash.length) { var hash = window.location.hash.replace('#', ''); $("#content").load(hash); } }); secondly, use cookies think hash way works fine, :)
Comments
Post a Comment