Good day. There is a working script, the url is changing, but I can’t understand how to dynamically change the title.

<script> $(function($){ $('#menu a').attr('onclick','return false;').click(function(){ var href = $(this).attr('href'); $('.conteiner').fadeOut(90); $('.conteiner').load(href+' .conteiner', function(){ history.pushState(null, null, href);$('.conteiner').fadeIn(600);return false; }); }); }); </script> 

Accordingly, there is a div with menu items and a div with the class of the conteiner loadable part of the content. Tried both pushState and replaceState but something doesn’t work. :(

  • thunder, thank you so much, it works! :)) - kampolWaMpIr
  • well and excellent) - thunder


1 answer 1

document.title="my new kewl title?"; not?

  • Nope, the title should be loaded ... it turns out, it should be enclosed in a separate class that will be used by the script and substituted after the execution of the main script, while it should be associated with the url address. - kampolWaMpIr
  • Duc and what does this cause to call inside your script? this is a common document property .... it has nothing to do with history. Zyz Essno his call will be tied to something) otherwise where will you take the title;) and here the url did not quite understand the address. - thunder
  • I myself did not understand the url account: D In principle, the title can be taken directly from the link itself (menu item), i.e. A title and blah blah blah, and already substitute it instead of the main title of the page. kb-iskra.ucoz.ru I am not familiar with js at all, I do everything by typing. - kampolWaMpIr
  • Yes, as you want, it is taken :) I don’t know how it works for you. if the content is being returned, for example, json, then you can shove a title in json ... well, in general, these are already implementation issues. it is possible to make some hidden field in the returned page and from there read the title ... - thunder
  • Well, now, the pianist is changing, stuck in the wrong place :) Now it remains only to load this title and insert my new kewl title instead? - kampolWaMpIr