Академический Документы
Профессиональный Документы
Культура Документы
4. Internet Programming
1
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Reference
H.M. Deitel, P.J. Deitel and T.R. Nieto, Internet
and World Wide Web: How to Program, Prentice
Hall, 2002
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Internet Programming
Web
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Internet
Database Web Server
Web Client
Server-side Programming
Client-side Programming
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
Provide
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
What is XHTML?
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
Features of XHTML
Platform independent
Text-based
The same piece of code can give the same display in Mac,
Linux and Windows
start tag
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
</head>
<body>
This is body, main part of the page
</body>
10
</html>
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
useful
usefulfor
forvalidating
validatingthe
thecode
codeto
to
see
seeififthey
theymeet
meetthe
thexhtml
xhtmlstandard
standard
comment
<!-- main.html -->
comment
<!-- Our first Web page -->
define
definethe
thenamespace
namespaceof
ofhtml
html
11
<body>
<p>Welcome to XHTML!</p>
</body>
</html>
<p> - new paragraph
Example
Example
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
12
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming - XHTML
An
body
13
section
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Tags
14
attribute name
attribute value
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
15
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
16
</body>
</html>
1
2
3
4
5
6
Header</h1>
header</h2>
header</h3>
header</h4>
header</h5>
header</h6>
66headers
headersare
areall
allused
used
to
toindicate
indicatethe
therelative
relative
importance
importanceof
oftext
text
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Text
Textunder
under<h1>
<h1>has
hasthe
thelargest
largestsize
size
17
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Meta Tag
HTML
18
<head>
<meta name=keywords content=lecture notes, html,
form, feedback>
<meta name=description content = this web site
describes >
</head>
Description
Descriptionof
ofaapage
pageseen
seenon
onsearching
searching
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Linking Webpage
One
Achieve
To a web page:
<a href=http://www.eie.polyu.edu.hk>PolyU</a>
anchor
anchorattribute
attribute
19
Value
Valueof
ofthe
theattribute:
attribute:
The
Theaddress
addressof
ofthe
theWeb
Webpage
page
The
Thename
nameon
onthe
theWeb
Web
page
pagethat
thatrepresents
representsthis
this
link
link
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
<body>
<h1>Here are my favorite
sites</h1>
strong
strongtag
taglets
letsthe
thetext
textto
tobe
be
displayed
displayedwith
withbold
boldfont
font
Other
Othersimilar
similartags
tagsinclude
include
<u>
<u>underline
underlineand
and<em>
<em>italic
italic
Four
Fourlinks
linkscreate
create
20
Dont
Dontintroduce
introducespaces
spacesbetween
between
different
differentparts
partsof
ofaaURL
URLaddress
address
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
This
Thisline
lineisisshown
shownwith
withaabold
boldfont
font
Four
Fourlinks
linksare
areincluded
included
21
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
a mail address:
a subject:
<a href=mailto:enpklun@polyu.edu.hk?subject=title>
Email me
</a>
Multiple
22
recipients:
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Linking Images
Background
To show
23
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Will
Willscale
scaleto
tothis
thissize
sizeto
todisplay
display
<body>
<p><img src = "xmlhtp.jpg"
height = "238 width = "183"
alt = "XML How to Program book cover"/>
<img src = "jhtp.jpg"
height = "238" width = "183"
alt = "Java How to Program book cover"/>
</p>
</body>
empty
emptyelement:
element:
do
donot
notmarkup
markuptext
text
24
jhtp.jpg
jhtp.jpgin
infact
factcannot
cannotbe
befound.
found.
With
Withthe
thealt
altattribute,
attribute,the
thestatement
statement
isisdisplayed
displayedififthe
theimage
imageisisnot
notfound
found
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
alt
altstatement
statement(may
(maynot
not
display
displaythe
thesame
samefor
for
Netscape)
Netscape)
The
Theimage
imagedisplayed
displayedatatthe
the
specified
specifiedsize
size
25
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Color
2
26
ways to specify:
Use hexadecimal numbers
RGB format: FF: strongest, 00 weakest
#FF0000
#00FF00
#0000FF
Use color names
Black, White, Red, Cyan, Green, Purple,
Magenta, Blue, Yellow, OrangeRed,
SpringGreen, BlueViolet, Gold,
DarkGoldenrod, Burlywood,
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Color
Background
Text
27
Font
color:
color:
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Formatting Text
28
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
background
backgroundcolor
colorisisyellow
yellow
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
size
size ==24
24
default
defaultsize
size
size
size==+1,
+1,+2,
+2,+3
+3
30
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Lists
Unordered
31
list
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Lists
Ordered
list
32
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Table
Organize
Table caption
Table header
Table body
Table footer
33
Table border
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
34
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
35
The
Thetrtrtag
taginsert
insert
aanew
newrow
row
content
contentof
ofheader
header
or
orfooter
footercells
cells
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
<tr>
<tfoot>
<td>Orange</td>
<tr>
<td>$0.50</td>
<th>Total</th>
</tr>
<th>$3.75</th>
<tr>
</tr>
<td>Banana</td>
</tfoot>
<td>$1.00</td>
</table>
</tr>
<tr>
<td>Pineapple</td>
The
<td>$2.00</td>
Theuse
useof
ofth
thtag
tag
</tr>
defines
the
defines
the
The
use
of
td
tag
The use of td tag
</tbody>
content of header
36
defines
definesthe
the
content
contentof
ofbody
body
cells
cells
content of header
or
orfooter
footercells
cells
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
37
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
<colspan=number>
data
<rowspan=number>
data
38
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
39
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
40
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Forms
When
browsing
web sites, users
often need to
provide information
such as email
address, search
keywords, etc
Forms allows user
to input information
41
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
App
CGI
Internet
Web Server
www.abc.com/form.htm
Web Client
1
2
www.abc.com
method = post or get
action = program name
(script) in server to
receive the data
Name = ???
42 and others
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
43
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
use
usepost
postmethod
method
script
scriptthat
thatwill
willbe
becalled
calledto
to
execute
executein
inthe
theserver
server
44
Only
Onlythe
theradio
radio
button
buttonof
oflarge
largeisis
checked
checked
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Forms
Elements
45
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Form example I
Thing
Thingthat
thatsends
sendsback
backto
toserver
server
The
Thewords
wordsshow
showon
onscreen
screen
46
Indicate
Indicateall
all55
checkboxes
checkboxes
belong
belongto
tothe
the
same
samegroup
group
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Form example II
Data
Datathat
thatwould
wouldsend
sendto
to
server
serverbut
butdo
donot
notdisplay
displayon
on
screen
screen
<input type="hidden" name=title" value="Feedback" />
<p><label>Name:
<input type= "text" name= "name" size="25"
maxlength="30"/>
</label>
send
the
input
the
textbox
to
server
send
the
input
the
textbox
to
server
</p>
<input type= "submit" value="Submit your entries"/>
<input type= "reset" value="Clear Your Entries"/>
47
clear
clearthe
thecontent
contentof
oftextbox
textbox
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
<p><label>Comments:<br />
<textarea name= "comments" rows="4" cols="36">
Enter your comments here.
</textarea> </label></p>
<p><label>Please input your password:
<input name= "secret" type="password" size="25"/>
</label></p>
<input type= "submit" value="Submit Your Entries"/>
48
<input type= "reset" value="Clear Your Entries"/>
ENG224
INFORMATION TECHNOLOGY Part I
4. Internet Programming
Form example IV
The
Theselected
selectedvalue
valuehere
here
mean
meanAmazing
Amazingisisselected
selected
default
defaultvalue
value
<p><label>Rate our site:
<select name= "rating">
<option value=Amazing
selected="selected">Amazing</option>
<option value=3>3</option>
Change
<option value=2>2</option>
Changeto
todefault
default
<option value=1>1</option>
value
valuewhen
whenreset
reset
<option value=0>0</option>
</select></p>
<input type= "submit" value="Submit Your Entries"/>
<input type= "reset" value="Clear Your Entries"/>
49