Answer the question
In order to leave comments, you need to log in
How to update the url in the address bar or what to do?
Stupid question.
I decided to make a simple site, without links. When you click on the menu, the main block is simply updated, or the finished text is simply entered, or it is loaded via ajax.
The problem is that the link in the browser naturally does not change and copy it and throw it to someone - he will naturally receive a link to the beginning, and not to the "submenu".
Which approach is correct in general - I'm not sure that I can replace the link in the address bar from JS.
But how then to get out of the situation? Creating a "copy link" button on each page seems to me not the most correct option.
Answer the question
In order to leave comments, you need to log in
If you want to do something similar to SPA (Single Page Application), then first you need to teach the server to always return index.html
. The next step is the History API, this will come in handy for URL spoofing and generating your links. And in order to download the necessary content, it will be necessary to parse location.pathname
and display the necessary information (as if you clicked on a menu item).
The second option is simpler - use it location.hash
to store a unique URL, you will upload the same as in the first option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question