GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing happycoding.io — Developer Tools Developer Tools
Previous:
Next:
Developer Tools
Before you get any further into web development, you should familiarize yourself with a set of tools that you’ll be using all of the time. These are the developer tools that come with every web browser. These developer tools let you get more information about a website, to debug your JavaScript, and to see why that one element is 5 pixels to the right of where it should be. Most browsers will be pretty similar: try pressing the
This shows the developer tools panel at the bottom (or the side) of your web browser. I like to pop this into its own window by going to the menu inside the developer tools panel, then undocking it into a separate window. This way I can keep the developer tools on one screen while I work in the webpage in the other, but it’s really up to you. Now that you have the developer tools open, let’s talk about what you’re looking at. JavaScript ConsoleThe If you’ve coded even a tiny bit of JavaScript, maybe you’ve noticed that when your code breaks, most of the time nothing happens. That’s because JavaScript doesn’t show a big warning message if something goes wrong, which is good because otherwise you’d scare everybody who used your webpage! But it also can make it hard to debug your code when something goes wrong. That’s where the JavaScript console comes in handy. Any errors your code generates will show up in the JavaScript console. So if your code isn’t working, the first thing you should do is check the JavaScript console. In fact, it’s probably a good idea to always have the JavaScript console open, because you might be getting errors you don’t even know about! This is also where calls to the Debugging with the JavaScript ConsoleLet’s say you have this JavaScript code: This example code might be a little obvious, but pretend you’re getting the value of the But before you go to Stack Overflow or the Happy Coding forum and proclaim that you found a bug in JavaScript, you should first test your assumptions. One of the best ways to do that is to add some print statements to your code to make sure it’s executing the way you think it is. For example, you might put a print statement inside the If you run that code, you won’t see the message print to the console. That tells you that the code is not entering the That new print statement shows up in the console, so finally you might print the value of This prints Inspect ElementAnother handy tool is the ability to inspect an HTML element. This lets you see the layout of the page, the styles of an element, and the output of any JavaScript that changes the page. You can inspect an element by right-clicking an element in the webpage itself, and then clicking Inspect in the menu. This will bring you to the Elements tab of the developer tools, with the element you clicked already selected.
You can use this to view an element’s CSS styles. This is really useful if you want to know exactly what’s causing an element to look a certain way. Also check out the Computed tab to show the final result of all of the cascading styles. You can also use this to change the styles of an element, which is a good way to play with different CSS values. Refreshing the page will restore the default styles. Try inspecting these elements: I'm a paragraph. I'm a link inside that paragraph.
Try playing with the styles inside your browser’s developer tools: add borders, change the size, change background colors. This is another handy tool for debugging the layout of your page. Network TabA webpage is usually multiple files: you might have one The This becomes really useful if you have stuff on your page that’s not loading correctly. Maybe you have an image that isn’t showing up. Check the network tab! This will show you any errors you’re getting on individual files. Learn MoreThe developer tools contain a ton more: you can test different kinds of internet connections, see what a website looks like on other devices, and even step through your JavaScript code with a debugger. Don’t be afraid to click around and experiment (and use your favorite search engine) to find out more! But the Console, Elements, and Network tabs will get you pretty far for now. Homework
Previous:
Next:
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |