Important attributes of <FRAME>
- SRC: This is a required attribute and takes the URL of a document to load in the frame.
- BORDERCOLOR: Defines color for the border. Both, color names and hexadecimal color codes are accepted values.
- FRAMEBORDER: Places a border. Values can be ‘1’ or ‘YES’ that display a border or ‘0’ or ‘NO’ which prevent border display.
- MARGINWIDTH: Defines the amount of space in pixels between the left and right hand sides of the frame and its contents.
- MARGINHEIGHT: Defines the amount of space in pixels between the top and bottom edges of the frame and its contents.
- NAME: Specifies a name for the frame that can be used for easy reference. This is especially helpful when using scripting languages such as JavaScript or VBScipt. We shall see its use soon.
- NORESIZE: Frames can be sized by the user if a border is present. By placing this attribute, you can prevent your visitors from resizing frames. This attribute takes no values.
- SCROLLING: The attributes taken are ‘YES’, ‘NO’ or ‘AUTO’. A value of ‘YES’ will display a scroll bar eventhough one is not required. ‘NO’ will prevent any scroll bars and ‘AUTO’ lets the browser to decide if the frame needs a scroll bar.
The code below explores these attributes in more detail:
<HTML> <HEAD><TITLE>My third framed page</TITLE> </HEAD> <FRAMESET COLS="20%, 80%" FRAMEBORDER="YES" BORDER="3"> <FRAME SRC="menu.html" NOSIZE SCROLLING="YES" NAME="menuframe" MARGINWIDTH="0" MARGINHEIGHT="5"> <FRAME SRC="main.html" NORESIZE SCROLLING="AUTO" NAME="mainframe"> </FRAMESET> <NOFRAMES> There is no frame support on your browser. </NOFRAMES> </HTML>
We’ll name this file frames3.html. You can test it by click here.
Though a border is displayed between frames you will not be able to drag it and resize the frames. This is because of NORESIZE attribute. (You can resize frames in frames.html).
The two frames now have names, the left is called menuframe while the right mainframe.
We have specified ‘YES’ as the value for SCROLLING attribute of menuframe, so a scroll bar is displayed.
MARGINHEIGHT attribute in menuframe puts a 5 pixel space between the top and bottom edges and the contents. MARGINHEIGHT with 0 value causes the contents of menuframe to be placed sticking to the left edge.
SCROLLING for mainframe has been set to AUTO, which places the decision of putting scroll bars on the browser. In our case, these bars are not required, hence not displayed.