Web pages do not keep track of state. Why, you ask? It’s simple. The reason why web pages do not keep track is because of memory usage. So, think about your computer and its RAM. What happens when you run one program? It probably runs pretty well, I imagine.
Now, open ten things and run them all at the same time. What happens? For example, open up Chrome and open 20 tabs, open Netflix and start watching a movie, open Photoshop and start editing an image, then watch a local film, edit a document, etc. You get the picture. Things start to crawl! That’s why they always say you should increase your RAM if you want your computer to run faster.
Now imagine all the users on the internet. If we were to try and keep track of all usage from page to page, imagine how much memory would be needed. The web server would not function well.
So, what can we do about it? Well, there are a couple of options. There are several ways to handle state:
There are a couple more, but they are beyond the scope of this class. So, we will focus primarily on the first two. If we have time, we will look into databases. (I hope we do!)
How do we implement the query string and use it?
Today, we are going to learn two ways we can navigate between two different pages.
The first technique is to use the document.window.location, and the second is to use the form tag. Let’s look at some examples!