CSE1041 - Web - 1 - Revampedweek3
CSE1041 - Web - 1 - Revampedweek3
Week 3
HTML (Frames & Forms)
1
Frames (1)
• At their simplest level, frames provide multiple
separately scrollable areas within one user window.
2
Frames (2)
• A frameset is created like any other HTML document except that its content is
limited to frame-related tags. The following skeletal code is an example of a
frameset document:
<html>
<head>
...
</head>
<frameset attributes>
<frame attributes></frame>
<frame attributes></frame>
...
</frameset>
</html>
3
Frame specific tags
• The document uses the frameset DTD. The frameset DTD is
essentially the same as the transitional DTD except for the
addition of the frame-specific tags (and replacement of the
<body> tag)
• The column or row sizes can be specified as percentages of the user agent
window; pixels; or an asterisk (*), which enables the user agent to assign the size.
• In the last case, the user agent typically splits the remaining space across the
columns or rows that specify * as their width.
• In any case, the resulting frameset will occupy the entire user agent window. The
number of entries of the cols or rows attribute also defines how many frames will
be used — each entry needs a corresponding <frame> tag within the <frameset>
tag.
5
Frameset Example
– <!-- Two columns, 25% of the window, the other 75% of the window -->
• <frameset cols = "25%, 75%">
– <!-- Two columns, 25% of the window, the other 75% of the window -->
• <frameset cols = "25%, *">
– <!-- Three rows, the first 50% of the window, the other two 25% of the window each -->
• <frameset rows = "50%, *, *">
– <!-- Two rows, the first 100 pixels high, the second is the size of the remaining window
space -->
• <frameset rows = "100px, 200px">
• In the above frameset example, the second row is defined at 200px. However, if
the user agent’s window is larger than 300 pixels high (the total of the rows
defined), the second row will be expanded to fill the space.
6
Frame Tag
• The frame tag (<frame>) is responsible for defining properties of each
frame.
• The name attribute gives the frame a unique name that can be referenced
by URLs, scripts, and so on to control the frame’s contents.
• The src attribute is used to specify the URL of the content the frame
should display.
• Using only these two attributes results in a frame with minimal margins,
no borders, and automatic scroll bars.
7
8
Tips on Frame
• When using images in a frame, consider setting the margins to zero so the graphic
fills the frame entirely without superfluous white space.
• The frameborder attribute controls whether or not the bounding border of the
frame is visible.
• The scrolling attribute controls whether the frame will display scroll bars. The
default setting, auto, allows the user agent to decide.
• The frame tag also has a noresize attribute that, when set, will not allow a user to
modify the frame’s size. The default is to allow the user to resize the frame.
• Investigate parent.news.location.href
9
Frame Example
10
Frame Example – The codes
<html>
<head>
<title> Main </title>
</head>
<frameset rows="*,7%" BORDER=1 FRAMESPACING=0>
<frameset cols="20%,80%" BORDER=1 FRAMESPACING=0>
<noframes>
Sorry, your browser does not handle frames!
</noframes>
</frameset>
</html>
11
Inline Frames
• Inline frames were conceived to enable smaller
pieces of content to be incorporated in scrollable
containers within a larger document.
14
Forms
• At first HTML was not designed to send data back to the server for
processing.
• Note: The action attribute defines a URL where the data from the form
should be sent to be handled.
• The destination should be a script or other construct capable of correctly
interpreting and doing something useful with the data.
15
Sending data to server
• Two ways to send data to server:
• 1. HTTP GET (get)
– The HTTP GET protocol attaches data to the actual URL text to pass the data to
the destination specified in the action attribute
– E.g http://www.on-target-games.com/forms.cgi?id=45677&data=Taarna
– Id and data values are visible - insecure!
16
Form example (1)
<html>
<head><title>hello</title></head>
<body>
<form id=myform action=“process.php" method="get">
Name: <input type=text name="txtname“/>
Password: <input type=password name=“txtpass“/>
<input type=submit name=submit value=“login”>
<input type=reset name=reset>
</form>
</body>
</html>
17
Form example (2)
<html>
<head><title>hello</title></head>
<body>
<form id=myform action=“process.php" method=“post">
Name: <input type=text name="txtname“/>
Password: <input type=password name=“txtpass“/>
<input type=submit name=submit value=“login”>
<input type=reset name=reset>
</form>
</body>
</html>
18
• Difference between the id and name attributes of the form
• The name attribute is used to uniquely reference a field value when a form
is passed to a form handler on the server side.
19
Form Elements - Button
• The button form control is an attempt at improving the humble "submit" button (input
type="submit"), which can only contain one line of text (the value attribute) and places
certain limitations on the possibilities for CSS styling.
20
Investigate Button Attributes
• Access key for button
21
22
Fieldset (2)
• The fieldset is a useful tool for organizing and
grouping related items within a form.
• Eg.
23
Input Tag
24
Input Tag attributes (1)
• accept=“MIME type”
– E.g <input type="file" name="picture" id="picture“
accept="image/jpeg"/>
• alt=“string”
• E.g <input type="image" src="submit.jpg“ alt="Submit your
details"/>
• checked=“checked”
– E.g <input type="checkbox" name="chknewsletter"
id="chknewsletter“ checked="checked"/>
• disabled="disabled“
– E.g <input type="checkbox" name="chknewsletter"
id="chknewsletter“ checked="checked" disabled="disabled"/>
• maxlength="number“
– E.g <input type="password" name="pin" id="pin" maxlength="4"
size="6"/>
25
Input Tag attributes (2)
• name="string“
– E.g <input type="password" name="pin" id="pin" maxlength="4"
size="6"/>
• readonly="readonly"
– E.g <input type="text" name="town" id="town" readonly="readonly"
value="Southampton"/>
• size="number"
– E.g <input type="password" name="pin" id="pin" maxlength="4"
size="6"/>
• src="uri"
– E.g <input type="image" src="submit.jpg" alt="Submit your details"/>
• tabindex="number"
– E.g <input type="password" name="pin" id="pin" tabindex="2"/>
26
Input type attribute
<button>
<h1>Click Me</h1>
</button>
29
Using an image as a submit button
• <input type=image src="images/bicycle.gif"
value="Submit">
30
Label Tag
32
Select Tag- Example
<select name=“nationality”>
<option value=“mru”>Mauritian</option>
<option value=“fr”>French</option>
<option value=“br”>British</option>
<option value=“it”>Italian</option>
</select>
33
Attributes for Option tag
• disabled="disabled"
– E.g <option disabled="disabled">Cabbage</option>
• label="string"
– E.g <option label="Cabbage">Cabbage (local produce)</option>
• selected="selected"
– E.g <option selected="selected">Egg</option>
• value="value"
– E.g <option value="1">Cheese</option>
– <option value="2">Egg</option>
– <option value="3">Cabbage</option>
• tabindex="number"
– E.g <input type="password" name="pin" id="pin" tabindex="2"/>
34
New Elements – canvas
• This is the output of Select tag.
• Investigate this
35
Textarea tag(1)
36
Textarea tag(2)
<textarea name="txt_others" cols=40
rows=3></textarea>
soup.jpg
link to souping.html and loads in same tab
piz.bmp
link to pizzaing.html and loads in new tab
menus.jpg and links to http://www.pizzahut.mu
38
References
• [1] Steven M. Schafer, HTML, XHTML, and CSS Bible, 5th
Edition (Wiley Publishing, 2010)
39