Routing with javascript | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Routing with javascript

Hello everyone, i want to make a simple web app that renders views based on the routes in the url using javascript, i want to know how to detect changes in url and reder corresponding views, and if someone gives me a simple example of doing this, this will be better.

4th Jan 2021, 7:43 PM
Salih Benlalla
Salih Benlalla - avatar
3 Réponses
+ 2
JaScript i mean like in reactjs there is already a package (BrowserRouter) that you can install with npm and import it in your code to get this fonctionnality, i want to do smoething similar with vanilla javascript, you can think of it as i want to know how this fonctionnality work behind the scenes, and recreate it with vanilla javascript. and if you never worked with react, i want to create a single page web app that changes views depending on url routes without refreshing the page or fetching new html document using anchor tag <a>
5th Jan 2021, 2:45 AM
Salih Benlalla
Salih Benlalla - avatar
+ 1
You have completed the HTML tutorial here. So you should know that if you are entering a new link in your webbrowser it will route to this website of above mentioned urlClientUser. And this is for you not enought and if I right understood you want to use javascript and route to another url e.g. urlMyJavaScript? Can you please explain it more detailed with an example, how do you image this function / feature?
4th Jan 2021, 9:04 PM
JaScript
JaScript - avatar