UNIT II Frames
Total Page:16
File Type:pdf, Size:1020Kb
UNIT II Frames : Introduction Frames divide a single browser window into multiple, independent regions, each of which can display a different HTML document. You begin by created FRAMESET document, which sets up the "layout" by establishing the number of frames, their position and other characteristics. This frameset document is structural only and does not contain any of the content that will appear on the final web page. It does however, specify a URL reference for each frame, which will be the HTML document, or "normal" web page that will be displayed within it. Hyperlinks in one frame can update the contents of another frame through the use of the TARGET attribute. Frames are controversial, however. Like many other web elements, such as background graphics, animations, and font colors, they can be poorly handled and often irritating, so give it some careful thought before you use them. Advantages of Frames 1. They allow parts of the screen to remain static while other parts scroll. This can be useful for navigation menus or logos that you don't want to scroll off the screen. 2. They can be handy when you want the user to be able to view a number of images chosen from a long list. 2. You can introduce material from different servers on the same page, simply by assigning the appropriate URL's. Disadvantages of Frames 1. Navigating through a framed site can be challenging for many users, as the forward and back buttons do not work as expected. 2. Bookmarking a framed site is difficult, as only the top level document is noted. Users have the ability to work around this by opening the frame of interest in a new window and bookmarking it, but they may not aware of that. 3. Since a framed page is loading more than one URL, it may load more slowly, particularly if calling upon different servers. 4. Frames present problems for search engine indexing. That said, let's get on with the exercise. The table below simulates a common layout on the web, consisting of a banner across the top of the browser window, with the remainder of the page divided into two columns. See example. For this exercise we need to create 4 documents, all within the same folder: 1. "frameset.html" - the frameset document itself. 2. "banner.html" - the banner that runs across the top of the browser window. 3. "column1.html - the page that will display in column one. This page will contain a hyperlink that will load an external web page into column two. 4. "column2.html" - the page that will display in column two when the frameset is first viewed. This page will be replaced by new content when the user clicks on the hyperlink in column one. Banner Column One Column Two frameset.html <HTML> <HEAD> Create the document head as usual, but without a body <TITLE>Frame Example</TITLE> tag. </HEAD> The first frameset defines the number of rows in the document and their height. This example creates two rows. The top row is 40 pixels high and the second can <FRAMESET rows="40,*"> vary in height. Values for height can be specified as an exact number of pixels, as a percentage, or can be variable with the use of an asterisk. Now indicate the source, or URL, of the web page to be displayed in the top row. In this example we'll use the <FRAME one we created called banner.html SRC="banner.html" name=top> Name=top simply identifies this particular frame. You may name it anything you like. Insert another frameset in the second row and specify two columns this time. Here the variables indicate <FRAMESET cols="230, *"> column width, and like row variables, can be expressed as the number of pixels, as a percentage, or can vary by using as asterisk. In this example we are setting the width of column one at 230 pixels and allowing column two to vary in width. <FRAME SRC="column1.html" name=col1> Give the URL source for each column, and name them. <FRAME SRC="column2.html" name=col2> </FRAMESET> Close both framesets. </FRAMESET> </HTML> Close the HTML tag, note there is no body tag to close 2. banner.html <HTML> <HEAD> <TITLE>Banner</TITLE> </HEAD> <BODY> Banner </BODY> </HTML> 3. column1.html <HTML> <HEAD> <TITLE>Column 1</TITLE> </HEAD> <BODY> <A HREF="http://www.life.uiuc.edu/" target=col2>Life Sciences</A> </BODY> </HTML> 4. column2.html <HTML> <HEAD> <TITLE>Column 2</TITLE> </HEAD> <BODY> This is Column 2 </BODY> </HTML> The <frameset> element HTML frameset tag and element 1. HTML frameset element defines a window within which subwindows can exist in the form of frames. 2. frame element starts with <frameset> tag and ends with </frameset> tag 3. A number of frames (subwindows) as well as framesets can be defined within frameset element. Syntax <frameset> </frameset> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/framset.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- 1"> <title>HTML frameset tag example > HTML tutorial | w3resource</title> </head> <frameset cols="33%,33%,33%"> <frameset rows="*,50%"> <frame src="page1.html"> <frame src="page2.html"> </frameset> <frame src="page3.html"> <frame src="page4.html"> </frameset><noframes></noframes> </html> The <frame> element he HTML Inline Frame element (<iframe>) represents a nested browsing context, embedding another HTML page into the current one. <iframe id="inlineFrameExample" title="Inline Frame Example" width="300" height="200" src="https://www.openstreetmap.org/export/embed.html?bbox=- 0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569 861898606&layer=mapnik"> The <noframes> element The <noframes> tag was used in HTML 4 to act as a fallback tag for browsers that did not support frames. What to Use Instead? Example Use the <iframe> tag to embed another document within the current HTML document: <iframe src="https://www.w3schools.com"></iframe> Images Audio and Video HTML5 features include native audio and video support without the need for Flash. The HTML5 <audio> and <video> tags make it simple to add media to a website. You need to set src attribute to identify the media source and include a controls attribute so the user can play and pause the media. Embedding Video Here is the simplest form of embedding a video file in your webpage − <video src = "foo.mp4" width = "300" height = "200" controls> Your browser does not support the <video> element. </video> The current HTML5 draft specification does not specify which video formats browsers should support in the video tag. But most commonly used video formats are − Ogg − Ogg files with Thedora video codec and Vorbis audio codec. mpeg4 − MPEG4 files with H.264 video codec and AAC audio codec. You can use <source> tag to specify media along with media type and many other attributes. A video element allows multiple source elements and browser will use the first recognized format − Live Demo <!DOCTYPE HTML> <html> <body> <video width = "300" height = "200" controls autoplay> <source src = "/html5/foo.ogg" type ="video/ogg" /> <source src = "/html5/foo.mp4" type = "video/mp4" /> Your browser does not support the <video> element. </video> </body> </html> This will produce the following result − Video Attribute Specification The HTML5 video tag can have a number of attributes to control the look and feel and various functionalities of the control − Sr.No. Attribute & Description autoplay 1 This Boolean attribute if specified, the video will automatically begin to play back as soon as it can do so without stopping to finish loading the data. autobuffer 2 This Boolean attribute if specified, the video will automatically begin buffering even if it's not set to automatically play. controls 3 If this attribute is present, it will allow the user to control video playback, including volume, seeking, and pause/resume playback. height 4 This attribute specifies the height of the video's display area, in CSS pixels. loop 5 This Boolean attribute if specified, will allow video automatically seek back to the start after reaching at the end. preload 6 This attribute specifies that the video will be loaded at page load, and ready to run. Ignored if autoplay is present. poster 7 This is a URL of an image to show until the user plays or seeks. src 8 The URL of the video to embed. This is optional; you may instead use the <source> element within the video block to specify the video to embed. width 9 This attribute specifies the width of the video's display area, in CSS pixels. Embedding Audio HTML5 supports <audio> tag which is used to embed sound content in an HTML or XHTML document as follows. <audio src = "foo.wav" controls autoplay> Your browser does not support the <audio> element. </audio> The current HTML5 draft specification does not specify which audio formats browsers should support in the audio tag. But most commonly used audio formats are ogg, mp3 and wav. You can use <source&ggt; tag to specify media along with media type and many other attributes. An audio element allows multiple source elements and browser will use the first recognized format − Live Demo <!DOCTYPE HTML> <html> <body> <audio controls autoplay> <source src = "/html5/audio.ogg" type = "audio/ogg" /> <source src = "/html5/audio.wav" type = "audio/wav" /> Your browser does not support the <audio> element. </audio> </body> </html> This will produce the following result − Audio Attribute Specification The HTML5 audio tag can have a number of attributes to control the look and feel and various functionalities of the control − Sr.No. Attribute & Description autoplay 1 This Boolean attribute if specified, the audio will automatically begin to play back as soon as it can do so without stopping to finish loading the data.