HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 6. USING EXTERNAL RESOURCES 70


ID, we can jump directly to this h1 when the webpage is loaded.


(There are other, obsolete ways to create a fragment ID target, but they are
not recommended and we do not reveal them here.)


6.12.3 script src=


Thescript taghas two flavors: external and immediate.



When the src attribute is specified, a JavaScript script will be retrieved from
the URL that is given (aaa in this example). This JavaScript will then be
executed immediately before the rest of the page is rendered.


The URL of this src=URL method can refer to static (unchanging) code,
but more usefully it can refer to aCGIprogram that generates the code
dynamically, to display a pageview count, or to display a quote of the day.



When the src attribute is not specified, the JavaScript is required to appear
immediately after thescript tag. It is bbb in this example. It will also be
executed immediately.



If both src and an immediate script are provided, the src takes priority. The
bbb is ignored.


6.12.4 link


The head portion of a webpage can include several items by reference, in-
cluding CSS style sheets.



In this example, a style sheet is sought at URL xxx, and if found is loaded.

Free download pdf