71
1 XP New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site

New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

1

XP

New Perspectives on Creating

Web Pages with HTML:

Using Frames in a Web Site

Page 2: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

2

XP

Objectives

� Create frames for a Web site

� Control the appearance and placement of frames

� Control the behavior of hyperlinks on a Web page with frames

� Use reserved target names to specify a target for a hypertext link

Page 3: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

3

XP

Objectives Continued

� Create a Web page that is viewable by browsers that support frames and by those that do not

� Modify the appearance of your frame borders

� Create and implement floating frames

Page 4: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

4

XP

Considerations for a Web Site

� A Web site grows in size and complexity, each page is dedicated to a particular topic or group of topics.

� one page might contain a list of hypertext links

� one page might display contact information for the company or organization

� one page might describe the business philosophy

� As more pages are added to a Web site, a designer may what to display information from several pages at the same time.

� Such considerations contributed to the creation of frames.

Page 5: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

5

XP

Advantages to Using Frames

� Frames can give more flexibility in designing your Web presentation.

� You can place information in different Web pages, removing redundancy.

� Frames can make your site easier to manage.

� Frames allows you to update only a few files rather than the whole.

� Web designers advocate creating both framed and non-framed versions for a Web site and giving users the option of which one to use.

Page 6: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

6

XP

Disadvantages to Using Frames

� The browser has to load multiple HTML files before a user can view the contents of the site increasing the waiting time for potential customers.

� Some older browsers cannot display frames.� Some users simply do not like using frames.� Some web authors feel that frames are too constricting, limiting flexibility in designing the layout of a Web page.

� There is concern that frames can use up valuable screen space.

� The source code is removed from the user.

Page 7: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

7

XP

Introducing Frames

� A frame is a section of the browser window capable of displaying the contents of an entire Web page. For example:

� the frame on the left may display the contents of a Web page containing a list of hyperlinks

� the frame on the right may display a Web page with product information

Page 8: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

8

XP

An Example of Frames

This figure shows a common use of frames: displaying a table of contents in one frame, while showing individual pages from the site on the another.

Page 9: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

9

XPActivating a Hyperlink within

Frames

This figure shows a list of hyperlinks that remain on the screen while the user navigates through the contents of the site.

Page 10: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

10

XP

Planning Your Frames

� Before you start creating your frames, it is a good idea to plan their appearance and how they are to be used. There are several issues to consider:

� What information will be displayed in each of the frames?

� How do you want the frames placed on the Web page?

� What is the size of each frame?

� Which frames will be static, that is, always showing the same content?

Page 11: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

11

XP

Planning Your Frames Continued

� Which frames will change in response to hyperlinks being clicked?

� What Web pages will users first see when they access the site?

� Should users be permitted to resize the frames to suit the needs?

Page 12: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

12

XP

An Example of a Frame Layout

This figure shows an example of a frame layout.

It is recommended to draw an example of what you would like your Web page to look like before you get started.

Page 13: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

13

XP

Creating a Frame Layout

� The <frameset> tag is used to store the

definitions of the various frames in the file. These definitions will typically:

� include the size and location of the frame

� include the Web pages the frames display

� The <frameset> code does not include an opening and closing <body> tag.

� the reason for this is that this HTML file displays the contents of other Web pages; technically, it is not a Web page

Page 14: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

14

XPSpecifying Frame Size and

Orientation

� To create a frame layout, you will use the rows and cols attributes of the <frameset>

tag.

� the rows attribute creates a row of frames

� the cols attribute creates a column of frames

� A frameset is defined by rows or columns, but not both.

� You must choose to layout your frames in either rows or columns.

Page 15: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

15

XPFrames Defined in

either Rows or Columns

This figure shows frame layouts in either

rows or columns.

Page 16: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

16

XP

The Frame Syntax

� The syntax for creating a row or column frame layout is:� <frameset rows=“row height 1, row height 2, row height 3, . . .”>

� row height is the height of each row

or� <frameset cols=“column width 1, column width 2, column width 3, . . .”>

� column width is the width of each column

Page 17: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

17

XP

Row and Column Sizes

� Row and column sizes can be specified in three ways:

� in pixels

� as a percentage of the total size of the frameset

� by an asterisk (*)

Page 18: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

18

XPDefining Rows and Columns

Using an Asterisk (*)

� The asterisk instructs the browser to allocate any unclaimed space in the frameset to the particular row or column.

� for example, the tag <frameset rows=“160,*”> creates two rows of frames.

� Specify at least one of the rows or columns of your <frameset> tag with an asterisk to ensure that the frames fill up the screen.

� You can use multiple asterisks.

� The browser divides the remaining display space equally among the frames with the asterisks.

� for example, the tag <frameset rows=“*,*,*”> creates three rows of frameswith equal heights.

Page 19: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

19

XP

Frames of Different Sizes

This figure shows frames of different sizes.

160 pixels wide 25% of the

width of

the display

area

whatever space is left

Page 20: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

20

XP

Creating Two Rows of Frames

tag creates two rows of

frames: the first 85

pixels high and the

second occupying the

remaining display area

In this code, the top row is used for the company logo, and the second row is used for the remaining content of the Web page.

A frame that is 85 pixels high should provide enough space to display the logo. The rest of the display area is occupied by the second row.

Page 21: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

21

XP

Specifying a Frame Source

� To specify a source for a frame, use the <frame> tag with the syntax: <frame src=“URL”>

� The URL is the filename and location of the page that you want to load.

� You must insert the <frame> tag

between the opening and closing <frameset> tags.

Page 22: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

22

XP

This figure shows a preview of the YCS

logo and its placement.

logo frame

rest of the

frames

Logo and Placement

Page 23: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

23

XPInserting a Frame for

the Head.htm File

Because this is the first <frame> tag,

the browser displays head.htm in the first

frame row.

Note that using the comment tag and indenting the <frame> tag a few

spaces helps make your HTML code easier to follow and interpret.

source for the

first frame

Page 24: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

24

XP

Nesting <frameset> Tag

� Remember that a frameset is defined by rows or columns, but not both.

� To create frames using both rows and columns, one frameset must be nested inside another.

� The interpretation of the rows and cols attributes changes slightly.

� for example, a row height of 25% does not mean 25% of the display area, but rather 25% of the height of the frame into which that row has been inserted (or nested)

Page 25: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

25

XPCreating a Nested Set of Frames

in the Second Frame Row

This specifies a width of 140 pixels for the first column, and whatever remains in the display area will be allotted to the second column.

two columns of

frames nested in the

second frame row

Page 26: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

26

XP

Nested Frames

This figure shows the content of two pages and their placement on the Web page.

table of

content

s frame

pages frame

links.htm home.htm

Page 27: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

27

XPSources for the Two Frames

in the Second Row

the table of

contents will

appear in the

third frame

the YCS home

page will appear

in the fourth

frame

This figure shows the code for two new frames. It is not necessary to indent the code, however, it can make the code easier to read and interpret.

Page 28: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

28

XPResult of Web Site

with Nested Frames

Page 29: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

29

XP

Web Site with Frames

The design of the frame layout could use some refinement.

The appearance of scroll bars may or may not be appropriate for the web pages.

heading extends beyond the frame

border, causing a vertical scroll

bar to be displayed

table of

contents frame home page

frame

Page 30: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

30

XPControlling the Appearance

of Your Frames

� You can control three attributes of a frame:

� scroll bars

� the size of the margin between the source document and the frame border

� whether or not the user is allowed to change the size of the frame

Page 31: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

31

XPControlling the Appearance

of Scroll Bars

� By default, scroll bars are displayed when the content of the source page cannot fit within the frame.

� You can override the default setting using the scrolling attribute.

� The scrolling syntax is: <frame src=“URL” scrolling=“scrolling”>

� scrolling can either be “yes” (to always display scroll bars) or “no” (to never display scroll bars)

� If you don’t specify a setting for the scrolling attribute, the browser displays scroll bars when necessary.

Page 32: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

32

XPRemoving the Scroll Bars

from the Logo Frame

If the complete text cannot be displayed after removing the scroll bars from a frame, you will need to modify the frame margin.

set the scrolling

attribute to “no” to

remove the scroll

bars

Page 33: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

33

XP

Controlling Frame Margins

� The following should be consider for frame margins:� the browser determines the amount of space between the content of the page and the frame border

� occasionally, the browser sets the margin between the border and the content too large

� the margin should be big enough to keep the source’s text or images from running into the frame’s borders

� the margin should not take up too much space, because you typically want to display as much of the source as possible

Page 34: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

34

XP

Specifying Margins Syntax

� The syntax for specifying margins for a frame is: <frame src=“URL” marginheight=“value” marginwidth=“value”>

� marginheight is the amount of space, in pixels, above and below the content of the page in the frame

� marginwidth is the amount of space to the left and right of the page

� If you specify only one, the browser assumes that you want to use the same value for both.

� Setting margin values is a process of trial and error as you determine what combination of margin sizes looks best.

Page 35: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

35

XPSpecifying the Margin

Sizes for the Frames

The margin height is set to 0 pixels.

The frame margin width is set to 10 pixels, to keep the page from running into the borders of its frame.

height of the margin

text for the logo frame

will be 0 pixels

height of the margin for the

home page will be 0 pixels

and the width of the margin

will be 10 pixels

Page 36: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

36

XPResult of Web Site

with Resized Frame Margins

Page 37: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

37

XP

Controlling Frame Resizing

� By default, users can resize frame borders in the browser by simply dragging a frame border.

� Some Web designers prefer to freeze, or lock, frames, so that users cannot resize them.

� this ensures that the Web site displays as the designer intended

� The syntax for controlling frame resizing is: <frame src=“URL” noresize>

� The noresize attribute is included within the <frame> tag to prevent users from modifying the size of the frame.

Page 38: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

38

XPWorking with Frames

and Hypertext Links

� By default, clicking a hyperlink within a frame opens the linked file inside the same frame.

� You can display hyperlinks in many ways:� in a different frame� in a new window� in the entire window

� When you want to control the behavior of hyperlinks in a framed page, there are two required steps:� give each frame on the page a name� point each hyperlink to one of the named frames

Page 39: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

39

XPFiles and Hyperlinks

in a Web Site

home.htm

philosph.htm

lessons.htm

tours.htm

staff.htm

Page 40: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

40

XP

Assigning a Name to a Frame

� To assign a name to a frame, add the nameattribute to the frame tag.

� The syntax for this attribute is: <frame src=“URL” name=“frame_name”>

� frame_name is any single word you assign to the frame

� case is important in assigning names: “information” is considered a different name than “INFORMATION”

Page 41: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

41

XP

Assigning a Name to Each Frame

Once the frames are named, the next task is to specify the target frame for each hyperlink.

the frame name

Page 42: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

42

XP

Specifying a Link Target

� You can use the target attribute to open a page in a specific frame.

� The syntax for this is: <a href=“URL” target=“frame_name”>

� frame_name is the name you’ve assigned to a frame on your Web page

� When a page contains dozens of hyperlinks that should all open in the same frame, HTML provides a way to specify a target frame for all the hyperlinks within a single page.

Page 43: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

43

XP

Assigning a Target to a Hyperlink

the Web page will

appear in the pages

frame

Make sure to test your hyperlinks.

Page 44: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

44

XP

Using the <base> Tag

� Use the <base> tag to specify the default target for hyperlinks in a frame layout.

� Appears in the HEAD section of the HTML file.

� Used to specify global options for the page.

� One of the attributes of the <base> tag is the target attribute, which identifies a default target for all of the hyperlinks in a page.

� The syntax for this attribute is: <base target=“frame_name”>

� frame_name is the name of the target frame

Page 45: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

45

XP

Using the <base> Tag Continued

� The <base> tag is useful when your page contains a lot of hypertext links that all point to the same target.

� Rather than adding the target attribute to each <a>tag, you can enter the information once with the <base> tag.

� You can still use the <base> tag even if your file contains links that point to a different target than the one specified in the <base> tag.

� The target in the <a> tag overrides any target specified in the <base> tag.

Page 46: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

46

XPSpecifying a Default Target

for all Hyperlinks

the target of all links

will be the pages

frame

Page 47: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

47

XP

Using Reserved Target Names

� Reserved target names are special names that can be used in place of a frame name as the target.

� They are useful in situations: � where the name of the frame is unavailable� when you want the page to appear in a new window

� when you want the page to replace the current browser window

� All reserved target names begin with the underscore character ( _ ) to distinguish them from other target names.

� Reserved target names are case-sensitive, they must be entered in lowercase.

Page 48: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

48

XP

Reserved Target Names

This figure describes the reserved target names.

Page 49: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

49

XP

Using the _Self Target Name

You can use the reserved target name, _self,

which overrides the target specified in the <base> tag

and instructs the browser to open the page in the same frame that contains the hypertext link.

page will appear in

the frame containing

the hyperlink

Page 50: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

50

XPUsing the _Top

Reserved Target Name

page will appear in

the full display area

To target a link to the full display area, you will use the _top reserved

target name.

The _top target is

often used when a framed page is accessed from another. It’s also used when you are linking to pages that lie outside your Web site altogether.

Page 51: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

51

XP

Using the <noframes> Tag

� Use the <noframes> tag to allow your Web site to be viewable using browsers that do or do not support frames.

� When a browser that supports frames processes this code, it ignores everything within the <noframes> tags and concentrates solely on the code within the <frameset> tags.

� When a browser that doesn’t support frames processes this code, it doesn’t know what to do with the <frameset> and <noframes> tags, so it ignores them.

� When you use the <noframes> tag, you must include <body> tags, this way, both types of browsers are supported within a single HTML file.

Page 52: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

52

XP

The <noframes> Syntax

� The syntax for the <noframes> tag is:

<html><head>

<title>Page Title</title>

</head>

<frameset>

Frame Definitions

</frameset>

<noframes>

<body>

Page Layout

</body></noframes></html>

Page 53: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

53

XP

Frameless Version of a Web Site

Page 54: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

54

XP

Inserting the Noframes Code

Web site will

contain no

frames

Page 55: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

55

XP

Frames and Browsers

� To test your Web page, use a browser that does not support frames.

� Another way of supporting browsers that do not display frames is to create a Web page that contains links to the framed and nonframed versions of your Web site.

� It is important to correctly identify the target for hyperlinks within frames.� by default, the target of the hyperlink will be the current frame

� Use the _top target to hyperlinks to documents that lie outside of the Web presentation.

Page 56: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

56

XP

Working with Frame Borders

� There are additional attributes you can apply to the <frame> tag that allow you to

change border size and appearance. For example:

� you can remove borders from your frames to free up more space for text and images

� you can change the color of the frame border so that it matches or complements the color scheme for your Web site

Page 57: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

57

XP

Setting the Border Color

� To change the color of a frame’s border, use the bordercolor attribute.

� The attribute can be applied either to an entire set of frames, using the <frameset> tag, or to individual frames, using the <frame> tag.

� The syntax for this attribute is: � <frameset bordercolor=“color”>

or� <frame bordercolor=“color”>

� color is either a color name or a color value

Page 58: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

58

XP

Setting the Border Color Continued

� Applying the bordercolor attribute to the <frameset> tag affects all of the frames

and nested frames within the set.

� If you apply the bordercolor attribute to a single <frame> tag, that particular

color of the border changes in Internet Explorer, but in Netscape Navigator, all of the frame borders change.

� View the page using different browsers and browser versions.

Page 59: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

59

XPWeb Site with Brown Frame

Border

Page 60: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

60

XP

Setting the Border Width

� Another way of modifying frame borders is to change their widths using the borderattribute.

� The border attribute can be used only in the <frameset> tag, and not in individual <frame> tags.

� The syntax for the border attribute is: <frameset border=“value”>

� value is the width of the frame borders in pixels

Page 61: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

61

XP

The frameborder Attribute

� Adding frameborder=“no” to a <frameset> tag removes the borders from

the frames in your page.

� by removing the borders, more space for the text and images in each of the Web pages is created

� Internet Explorer also supports the framespacing attribute, which has the same effect as the border attribute.

� Netscape does not support the framespacing attribute.

Page 62: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

62

XP

Removing the Frame Borders

setting the width of

the frame border to

zero has the effect

of removing the

border

Some Web designers prefer not to show frame borders in order to give the illusion of having a single Web page rather than three separate ones, while other Web designers believe that hiding frame borders can confuse users as they navigate the Web site.

Page 63: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

63

XP

Web Site without Frame Borders

Page 64: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

64

XP

Creating Floating Frames

� Another way of using frames is to create a floating frame.

� A floating frame, or internal frame, is displayed as a separate box or window within a Web page.

� The frame can be placed within a Web page in much the same way as an inline image.

Page 65: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

65

XP

The Floating Frames Syntax

� The syntax for a floating frame is: <iframe src=“URL” frameborder=“option”></iframe>

� URL is the name and location of the file you want to display in the floating frame

� the frameborder attribute determines whether the browser displays a border (“yes”) or not (“no”) around the frame

� in addition to these attributes, you can use some of the other attributes you used with fixed frames, such as the marginwidth, marginheight, and name attributes

Page 66: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

66

XPAttributes Associated with the <iframe> Tag

This figure shows some of the other attributes associated with the <iframe>

tag.

The location and filename of the page displayed in the

frame

src="URL"

Specifies whether the frame can be scrolled ("yes") or not

("no")

scrolling="type"

The name of the framename="text"

The size of the internal margins of the frame, in pixels.marginheight="value"marginwidth="value"

The horizontal and vertical space around the frame, in

pixels

hspace="value"

vspace="value"

The height and width of the frame, in pixelsheight="value"width="value"

The class identifier of the objectclassid="URL"

Specifies whether to display a border ("yes") or not ("no")frameborder="type"

The size of the border around the frame, in pixelsborder="value"

How the frame is aligned with the surrounding text (use

"left" or "right" to flow text around the inline frame.)

align="alignment"

DescriptionAttribute

Page 67: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

67

XP

Creating a Floating Frame

HTML code to

create a floating

frame

Page 68: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

68

XP

Viewing a Floating Frame

floating

frame

If you want to use floating frames in your Web page, you must make sure that your users are running at least Internet Explorer 3.0 or Netscape 6.2. Users of other browsers and browser versions might not be able to view floating frames.

Page 69: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

69

XPAn Example of a

Web Site with Frames

Page 70: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

70

XP

Changing Web Page Content

� When changing Web page content, you may want to reload or refresh the Web page:

� for Netscape, you will need to close and then open the file for the changes to the frames to take effect. Simply clicking the Reload button, your changes are not displayed

� for Internet Explorer 3.0 and above, in which you can view changes to the page by clicking the Refresh button

Page 71: New Perspective on Creating Web Pages with HTML Using Frames€¦ · 2/10/2009  · New Perspectives on Creating Web Pages with HTML: Using Frames in a Web Site. 2 XP Objectives Create

71

XP

Summary

• Learned how to display multiple Web pages in a Web browser using frames.

• Learned how to create a frame layout and specify the source document for each frame.

• Learned how to control the behavior and appearance of each frame.

• Learned how to specify which frame will contain the results of an activated hyperlink

• Learned how to support "frame-blind" browsers.

• Discussed extensions of frames supported by some browsers.