Generally, the framework abstracts common tasks and makes it easier and faster for designers and developers to write their specific code. Frameworks don't really do anything by themselves, they just provide an easier platform for people to build on. Of these frameworks, JQuery is currently the most popular one. It's also the one you're most like to encounter being used as a buzz word. Many JavaScript files can tend to be rather large, which can slow down the load time of your page.
Learn JavaScript and other web development technology concepts through easy-to-understand explanations written in plain English. How to open JavaScript files without running it Here's how to open JavaScript files safely without running it Posted on July 22, A JavaScript file is a regular computer file that ends with the. When you double click on a. JavaScript Open With Opening JS file using Microsoft Word. Use the knowledge from the book to build a small but solid program.
JavaScript was originally created as a client-side language. Client-side JavaScript is delivered to web browsers by a web server.
The people visiting your site download your web page and its JavaScript, and then their web browser—the client—processes the JavaScript and makes the magic happen. Server-side programming languages, as the name suggests, run on a web server. They can exhibit a lot of intelligence by accessing databases, processing credit cards, and sending email around the globe. The problem with server-side languages is that they require the web browser to send requests to the web server, forcing visitors to wait until a new page arrives with new information.
Client-side languages, on the other hand, can react immediately and change what a visitor sees in his web browser without the need to download a new page. Content can appear or disappear, move around the screen, or automatically update based on how a visitor interacts with the page.
This responsiveness lets you create websites that feel more like desktop programs than static web pages. You can also use plug-ins to add programming smarts to a web page. Java applets are one example. These are small programs, written in the Java programming language, that run in a web browser. They also tend to start up slowly and have been known to crash the browser.
Flash is another plug-in based technology that offers sophisticated animation, video, sound, and lots of interactive potential. For example, Google Maps could also be created in Flash in fact, Yahoo! Maps was at one time a Flash application, until Yahoo! Ajax is a method for using JavaScript to talk to a server, retrieve information from the server, and update the web page without the need to load a new web page.
Google Maps uses this technique to let you move around a map without forcing you to load a new web page. These days, JavaScript is finding a lot of use outside of the web browser. In addition, some relatively new databases even use JavaScript as the language for creating, retrieving, and updating database records. You may hear the term full-stack JavaScript, which means using JavaScript as the language for the client-side browser, the web server, and database control. One language to rule them all!
Finally, because all of the code for the JavaScript program would be located in every web page, each page will be that much larger and slower to download. A better approach is to use an external JavaScript file.
An external JavaScript file is a text file containing JavaScript code and ending with the file extension. For example, to add this JavaScript file to your home page, you might write the following:.
In other words, it points to a file either in your website or on another website see the box on URL Types. For example:. You can and often will attach multiple external JavaScript files to a single web page. For example, you might have created one external JavaScript file that controls a drop-down navigation panel, and another that lets you add a nifty slideshow to a page of photos. In addition, you can attach external JavaScript files and add a JavaScript program to the same page like this:.
The home page top includes a row of navigation buttons along the top—Men, Women, Kids, and so on—that, when moused over, reveal a panel of additional navigation options. For example, mousing over the Sports button circled in bottom image reveals a panel listing different sports that Nike makes products for.
There are three types of paths: absolute path, root-relative path , and document-relative path. All three indicate where a web browser can find a particular file. An absolute path is like a postal address—it contains all the information needed for a web browser located anywhere in the world to find the file. A document-relative path specifies the path from the web page to the JavaScript file.
For example, suppose you have a JavaScript file named site. Root-relative paths are good for JavaScript files stored on your own site. Because they always start at the root folder, the URL for a JavaScript file will be the same for every page on your website, even when web pages are located in folders and subfolders on your site.
You can create an external JavaScript file, attach it to a web page, and then check the JavaScript in a web browser simply by opening the web page off your hard drive. This book uses document-relative paths, which will let you follow along and test the tutorials on your own computer without a web server. Sometimes the order in which you attach external JavaScript files matters.
The best way to learn JavaScript programming is by actually programming. The tutorial files are stored as a single Zip file. In Windows, download the Zip file and double-click it to open the archive. Click the Extract All Files option, and then follow the instructions of the Extraction Wizard to unzip the files and place them on your computer.
If you have trouble opening the Zip file, the free 7-Zip utility can help: www. On a Mac, simply double-click the file to decompress it. To get your feet wet and provide a gentle introduction to JavaScript, your first program will be very simple:.
In your favorite text editor, open the file hello. It informs the web browser that the stuff following this tag is JavaScript. Press the Return key to create a new blank line, and type :. The JavaScript alert function is a command that pops open an Alert box and displays the message that appears inside the parentheses—in this case, hello world. The code should now look like this :. In this example, the stuff you just typed is shown in boldface. The two HTML tags are already in the file; make sure you type the code exactly where shown.
Launch a web browser and open the hello. A JavaScript Alert box appears see Figure Notice that the page is blank when the alert appears.
Double-check your typing and read the following Tip.
0コメント