CSS UNIT 5
CSS UNIT 5
HTML frames are used to divide your browser window into multiple
sections where each section can load a separate HTML document. A
collection of frames in the browser window is known as a frameset.
The window is divided into frames in a similar way the tables are
organized: into rows and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never
recommended to use frames in your webpages −
• Some smaller devices cannot cope with frames often because
their screen is not big enough to be divided up.
• Sometimes your page will be displayed differently on different
computers due to different screen resolution.
• The browser's back button might not work as the user hopes.
• There are still few browsers that do not support frame
technology.
//f1.html
<html>
<head>
<title>Frame-1</title>
</head>
<body>
<p>Welcome</p>
</body>
</html>
//f2.html
<html>
<head>
<title>Frame-2</title>
</head>
<body>
<p>to</p>
</body>
</html>
//f3.html
<html>
<head>
<title>Frame-3</title>
</head>
<body>
<p>GGSP</p>
</body>
</html>
//fdemo2.html
<html>
<frameset cols = "25%,50%,25%">
<frame name = "left" src = “f1.htm" />
<frame name = "center" src = “f2.htm" />
<frame name = "right" src = “f3.htm" />
</frameset>
</html>
The <frameset> Tag Attributes
IFrames
• You can define an inline frame with HTML tag <iframe>.
• The <iframe> tag is not somehow related to <frameset> tag,
instead, it can appear anywhere in your document.
• The <iframe> tag defines a rectangular region within the
document in which the browser can display a separate
document, including scrollbars and borders.
• An inline frame is used to embed another document within
the current HTML document.
• The src attribute is used to specify the URL of the document
that occupies the inline frame.
<html>
<body>
<p>Document content goes here...</p>
//f1.html
<html>
<head>
<title>Frame-1</title>
</head>
<body>
<p>Welcome</p>
</body>
</html>
▪ PROGRAM
//Fdemo3.html
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "10%,80%,10%">
<frame name = "f1" src = "f1.html" frameborder="0"
border="0"/>
<frame name = "f2" src = "f2.html" frameborder="0"
border="0"/>
<frame name = "f3" src = "f3.html" frameborder="0"
border="0"/>
</frameset>
</html>
//f1.html
<html>
<head>
<title>Frame-1</title>
</head>
<body>
<p>Welcome</p>
</body>
</html>
//f2.html
<html>
<head>
<title>Frame-2</title>
</head>
<body>
<p>to</p>
</body>
</html>
//f3.html
<html>
<head>
<title>Frame-3</title>
</head>
<body>
<p>GGSP</p>
</body>
</html>
➢ 5.2.3 Calling a child window
Main Window :-
PROGRAM:
//fdemo4.html
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "50%,50%">
<frame name = "frame1" src = "f4.html" frameborder="0"
border="0"/>
<frame name = "frame2" src = "f5.html" frameborder="0"
border="0"/>
</frameset>
</html>
//f4.html
<html>
<head>
<script>
function show()
{
alert("Inside Frame1");
}
</script>
</head>
<body>
<input type="button" onclick="show()" value="Click
Here"/>
</body>
</html>
//f5.html
<html>
<head>
<script>
function show()
{
alert("Inside Frame2");
}
</script>
</head>
<body>
<input type="button" onclick="show()" value="Click
Here"/>
</body>
</html>
5.2.4 Changing content and focus of window
• You can give any child window the focus by changing the focus
after all the web pages have loaded in their corresponding child
windows.
• You do this by calling the focus() method of the child window,
as shown next, where the focus is being given to the web page
that appears in the bottomPage child window.
• You can call the focus() method from a JavaScript function or
directly in response to an event such as the onclick event.
▪ PROGRAM:-
//Wpage1.html
<html>
<head>
<title>Web Page 1</title>
<script language="Javascript" type="text/javascript">
function ChangeContent()
{
parent.topPage.location.href='WPage3.html'
}
</script>
</head>
<body>
<P>
<INPUT name="WebPage1" value="Web Page 1"
type="button" onclick="ChangeContent()"/>
</P>
</FORM>
</body>
</html>
//Wpage2.html
<html>
<head>
<title>Web Page 2</title>
</head>
<body>
<FORM action="http://www.jimkeogh.com" method="post">
<P>
<INPUT name="WebPage2" value="Web Page 2"type="button" />
</P>
</FORM>
</body>
</html>
//WPage3.html
<html>
<head>
<title>Web Page 3</title>
</head>
<body>
<FORM action="http://www.jimkeogh.com" method="post">
<P>
<INPUT name="WebPage3" value="Web Page 3"
type="button" />
</P>
</FORM>
</body>
</html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "10%,80%,10%">
<frame name = "f1" src = "f1.html" frameborder="0"
border="0"/>
<frame name = "f2" src = "f2.html" frameborder="0"
border="0"/>
<frame name = "f3" src = "f3.html" frameborder="0"
border="0"/>
</frameset>
</html>
5.3 Rollover
Rollovers are used to make a dreary web page come alive, by altering
its appearance as the visitor scans the contents of the web page with
the mouse. Any object on a web page can be changed with a
rollover. Some web developers change an image that is related to
the object beneath the mouse cursor. Other web developers pop up
a new window that further describes the object. The only limitation
is your imagination.
▪ PROGRAM:-
//RDemo1.html
<html>
<head>
<title>Frame-1</title>
</head>
<body>
<IMG height="92" src="rose1.jpg" width="70" border="0"
onmouseover="src='rose2.jpg'">
</body>
</html>
➢ 5.3.2 Text Rollover
• You can create as many rollovers as you want on your web
page; however, each one should be meaningful to the visitor.
There is nothing more distracting to a visitor than to encounter
rollovers on practically every object on a web page. Carefully
placed rollovers can enhance a visitor's experience when
browsing the web page. A clever rollover technique used by
some developers is to enable a visitor to see additional
information about an item described in text by placing the
mouse cursor on the text. This eliminates the time-consuming
task of using a hyperlink to display another web page that
contains this additional information and reduces the
information clutter found on some web pages.
➢ You create a rollover for text by using the onmouseover
attribute of the <A> tag, which is the anchor tag. You
assign the action to the onmouseover attribute the same
way as you do with an <IMG> tag. One thing must be
done; the onmouseover attribute must change the src
attribute of the <IMG> tag. Therefore, the value assigned
to the onmouseover attribute needs to identify explicitly
the <IMG> tag that is being changed. To do this, we must
give the <IMG> tag a unique name by assigning the name
to the name attribute of the <IMG> tag. We can then
reference the name in the value assigned to the
onmouseover attribute of the text's <A> tag. The
following segment shows how this is done.
▪ PROGRAM:-
//RDemo2.html
<html>
<head>
<title>Rollover Text</title>
</head>
<body>
<TABLE width="100%" border="0">
<TBODY>
<TR vAlign="top">
<TD width="50">
<a>
<IMG height="92" src="rose1.jpg" width="70" border="0"
name="cover">
</a>
</TD>
<TD>
<IMG height="1" src="" width="10">
</TD>
<TD>
<A onmouseover="document.cover.src='rose2.jpg'">
<B><U>Picture1</U></B>
</A>
<BR>
<A onmouseover="document.cover.src='rose3.jpg'">
<B><U>Picture2</U></B>
</A>
<BR>
<A onmouseover="document.cover.src='rose4.jpg'">
<B><U>Picture3</U></B>
</A>
</TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
//RDemo3.html
<html>
<head>
<title>Open Window</title>
<script language="Javascript" type="text/javascript">
var MyWindow
function OpenNewWindow(sel)
{
if(sel==1)
{
document.cover.src='rose1.jpg'
MyWindow1 = window.open('','myAdWin1','height="50"
width="150"')
MyWindow1.document.write('Mouse is on Link1 ')
}
if(sel==2)
{
document.cover.src='rose2.jpg'
MyWindow2 = window.open('','myAdWin2','height="50"
width="150"')
MyWindow2.document.write('Mouse is on Link2 ')
}
if(sel==3)
{
document.cover.src='rose3.jpg'
MyWindow3 = window.open('','myAdWin3','height="50"
width="150"')
MyWindow3.document.write('Mouse is on Link3 ')
}
}
</script>
</head>
<body>
<TABLE width="100%" border="0">
<TBODY>
<TR vAlign="top">
<TD width="50">
<a>
<IMG height="92" src="rose4.jpg" width="70" border="0"
name="cover">
</a>
</TD>
<TD>
<IMG height="1" src="" width="10">
</TD>
<TD>
<A onmouseover="OpenNewWindow(1)">
<B><U>Java Demystified </U></B>
</A>
<BR>
<A onmouseover="OpenNewWindow(2)">
<B><U>OOP Demystified</U></B>
</A>
<BR>
<A onmouseover="OpenNewWindow(3)">
<B><U>Data Structures Demystified</U></B>
</A>
</TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
▪ PROGRAM:-
//RDemo4.html
<html>
<head>
<title>More Efficient Rollover</title>
<script language="Javascript" type="text/javascript">