A
A
AlexandraSvetik2019-06-27 07:55:34
JavaScript
AlexandraSvetik, 2019-06-27 07:55:34

How can I fix the code so that it works properly?

Good afternoon everyone, I encountered a bug after loading a page in a block without reloading the entire page (as in VK).
Everything works except urland titleit looks like this if you use the code

http://сайт/услуги/тип-услуги/услуга#услуги/тип-услуги/услуга

and titleremains the same as it was
How to do it like this:
http://сайт/услуги/тип-услуги/услуга
to change title
Here is the code itself

$(document).ready(function() {
  // Check for hash value in URL
  var hash = window.location.hash.substr(1);
  var href = $('#nav-page li a').each(function(){
    var href = $(this).attr('href');
    if(hash==href.substr(0,href.length-5)){
      var toLoad = hash+'.html #content-page';
      $('#content-page').load(toLoad)
    } 
  });

  $('#nav-page li a').click(function(){
    var toLoad = $(this).attr('href')+' #content-page';
    $('#content-page').hide('fast',loadContent);
    $('#load-page').remove();
    $('#content-page').append('LOADING...');
    $('#load-page').fadeIn('normal');
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
    function loadContent() {
      $('#content-page').load(toLoad,'',showNewContent())
    }
    function showNewContent() {
      $('#content-page').slideDown('normal',hideLoader());
    }
    function hideLoader() {
      $('#load').fadeOut('normal');
    }

    var title = $('.title-page').text();
    var bread = $('.breadcrumb-item-page').text(); 
    $('.breadcrumb-item-page').text(title);
    
    return false;
  });
});


Please help I would be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
archelon, 2019-06-27
@archelon

change the title (but why?): about the url: - does not change the entire url, but adds a hash to it (the one after the symbol ). this may be useful and necessary in a number of cases, but here it is clearly the wrong approach.

A
amambaru, 2017-08-30
@myspace

A computer with 3-4 modems is the easiest to get. And probably the cheapest.
Or a raspberry-type microcomputer.
In general, there are such solutions, just for data centers
https://habrahabr.ru/post/240943/
Or here on the Toaster
Device for working with a large number of SIM cards at the same time?
What is the device for receiving SMS from many SIM cards at the same time?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question