javascript - AJAX SEO - back & forward buttons -
i'm using ben almans plugin hash change tracking:
http://benalman.com/projects/jquery-hashchange-plugin/
also i've modified web configuration when enter www.mysite.com/test1
, php grabs string test1 value, forwards javascript. javascript sends through ajax sever side script , brings test1 page.
and after user writing www.mysite.com/test1
in address bar gets test1 page. ok.
now. if enter www.mysite.com
, see index page, , there link test1 page. if press it, makes address www.mysite.com/#test1
, because of #
hash change plug-in can bring using ajax when press button.
what want have such hash change plug-in or method or system not need #
signs. cause want user see same clean address www.mysite.com/test1
.
is possible?
that's not possible. #
prefix hash part of location. hashes not sent server, , thus, changing hash won't cause page request.
when omit sharp (that's name of #
character), page request initiate.
if want seo url's, recommend use this"
<script> $(document).ready(function(){ var base_url = location.protocol + "//" + location.host + "/"; $("a[href^='+base_url+']").bind("click", function(ev){ location.hash = $(this).href.substr(base_url.length) ev.preventdefault(); }) }); </script> <a href="http://www.mysite.com/test1">link</a>
this bind onclick
@ each <a>
element in document, href
attribute starts base url.
Comments
Post a Comment