HTML and CSS Reference
In-Depth Information
properties or methods (built-in functions) of the
document
separated by a dot (
.
). For
example,
document
.
forms
.
fred
;
addresses a form named
fred
within a document. h e HTML5 markup looks like the
following:
<
form name
=
“fred”
>
Other times, you'll see a built-in function that does something with the document such as,
document
.
write
(
“This is straight from the Document”
);
which prints text on the screen. Also, the
window
root along with the document has several
built-in functions that are useful for manipulating viewing areas of a Web page.
HOW THE DOM WORKS WITH YOUR PAGE AND JAVASCRIPT
To get a better sense of how the DOM works with your page and JavaScript, it helps to
see what can be done with a Web page's windows — the viewing part of your Web page.
h e following (
PageOpener.html
in this chapter's folder at
www.wiley.com/go/
smashinghtml5
) shows how to load a new Window from a current document, leaving
the current page in place.
240
<!
DOCTYPE HTML
>
<
html
>
<
head
>
<
style type
=
”text/css”
>
a
{
text
-
decoration
:
none
;
color
:
#cc0000;
font
-
size
:
24px
;
}
header
{
text
-
align
:
center
;
}
</
style
>
<
script type
=
”text/javascript”
>
function someOtherWindow
()
{
window
.
open
(
“OtherWindow.html”
,
”ow”
,
”width=400,height=200”
);
}
</script>
<
meta http
-
equiv
=
”Content-Type”
content
=
”text/html; charset=UTF-8”
>
<
title
>
Open Other Page
</
title
>
</
head
>