Tell me, please, how to implement such functionality. From the main page of the site there are two links to another page (the same one). How to make, what at transition according to one link one event was carried out, and under the second link another (in this case assignment of different classes diva)?

Interested in the option without anchors ("#" in the address bar - interferes with the filter located on the page, and it is very difficult to pick it).

  • In my opinion, your js script will break when you try to open such a link in a new window - Vitaly Leonov

3 answers 3

  • You can send a post-request when you click on a link (a script or just make a submit type), and the server will produce a different result based on the transferred value (only when the page is refreshed, the browser will ask if the form should be sent again)

  • If you are satisfied, you can send a get-request, only in the url there will be infa (after?, But the anchors # are not needed here).

  • You can also write a cookie using javascript and on the basis of the click
    server will work.

In general, the simplest and most natural option is a get request (just change the link accordingly), if you are not satisfied, look at the situation (however, it is worth remembering that the user may have cookies and javascript disabled).

    Use the cookie library to record which link was followed.

      In the click handler for the link, save any information in sessionStorage (preferably) or to one of the places where the data will be saved when switching to another page.

      And on that page check this data and perform the necessary actions.
      Just do not forget to erase this data from the storage later.

      PS: In general, the very idea of ​​doing this is bad.