ducas.blogg.se

Javascript get element by name
Javascript get element by name












javascript get element by name

You have transitioned from Home to About Us without any server request having fired. Assuming your about page does not need to make any REST calls, it's done already. Instead, React Router does its thing on the client-side, determines which React view to render, and renders it.

javascript get element by name

In phase 2, when the user clicks on the 'About us' navigation link, for example, the URL is changed locally only to (made possible by the History API), but no request to the server is made. Only when those scripts have loaded does phase 2 start. That will then return a page that contains the needed script tags to load React and React Router etc. So the very first request will always be to the server. At first, the client does not have any JS code loaded yet. With client-side routing, which is what React-Router provides, things are less simple. In the past, when life was simple, some user sent a request for to the server, which inspected the path part of the URL, determined the user was requesting the about page, and then sent back that page. The first big thing to understand about this is that there are now 2 places where the URL is interpreted, whereas there used to be only 1 in 'the old days'.

javascript get element by name

So this answer is intended as background info / elaboration on the specific use case of the OP. Looking at the comments on the accepted answer and the generic nature of this question ('don't work'), I thought this might be a good place for some general explanations about the issues involved here.














Javascript get element by name