HTML and CSS Reference
In-Depth Information
As soon as the user clicks OK, the Web page loads. In the meantime, you can see the i les
from the directory in the background on your mobile device. Additionally, notice that the
alert window shows the domain where the JavaScript resides. Some browsers, such as Google's
Chrome, i rst check to see if the user wants to accept the JavaScript from the named site
before it shows the actual alert (a double alert!).
90
Figure 5-3: Alert window loading before Web page.
As with style sheets, JavaScript programs can be loaded from external i les. However, instead
of using the link element, the JavaScript i les are loaded using the script element, as the
following example shows:
< script type = ”text/javascript” src = ”smashingJS.js” ></ script >
h e JavaScript i le is saved using the .js extension, just as CSS3 i les are saved using the .css
extension.
You'll see JavaScript is employed a good deal when using the <canvas> tag and several other
HTML5 tags in Part IV of this topic. Further, <script> tags and the JavaScript code in them
can be added right in the middle of an HTML5 script. h e advantage of placing your JavaScript
in the head container, though, is that it's loaded i rst, before the Web page.
 
Search WWH ::




Custom Search