Correct Framesets for JavaScript

Correct Framesets for JavaScript thumbnail
JavaScript lets your web page visitors open and close frames.

With a correctly designed frameset (a group of contiguous rectangles within a web page), you can use JavaScript code to quickly change content within your web page's frames. Designing a correct frameset is not hard. You just need to follow the HTML syntax and rules for defining the frameset and name the framesets properly. Once done, you just need to use the correct JavaScript code to switch content in and out of your frames.

  1. Frameset Usage

    • Framesets are coded with HTML markup language with the "<FRAMESET>" tag. The FRAMESET tag is used to specify whether a frameset is a column frameset (a group of contiguous rectangles arranged vertically) or a row framset (a group of contiguous rectangles arranged horizontally). The tag "<FRAMESET cols="100,*">" for example, creates two columns: one that is 100 pixels wide and another column that extends the remaining width of the browser window. A correctly coded FRAMESET must always include an "*" column or row so that the frames display correctly in the browser window.

    Frameset Content

    • The content that is placed inside a frame within a frameset is coded with the "<FRAME SRC>" tag. The tag is assigned an attribute that identifies the name of file, such as a graphic file or a web page file, that will be placed into the frame. A name attribute must also be assigned in the FRAME SRC tag so that the JavaScript code can switch different content into and out of a specific frame column or row. The tag "<FRAME SRC="theexample.htm" name="cities">" for example, assigns the name "cities" to the frame column that the contents of the file "theexample.htm" is placed into.

    JavaScript Frame Content Control

    • A JavaScript function is often used to control which content (which file) is placed into which frame. Within the JavaScript function this is accomplished by selecting the frame name assigned within the document directory of the HTML file and equating it to the file that is to be loaded. For example the JavaScript code "parent.cities.location = "secondpicture.htm" " will load the file "secondpicture.htm" into the frame column (or row) named cities.

    JavaScript Function Call

    • Within an HTML document, the JavaScript function that switches the content of a frame is often executed when a link on the web page is clicked. For example, the code "<A HREF="javascript:changeContent()">Load a New Web Page into a Frame</A>" is used to create a link that will call a JavaScript function called "changeContent" when the link labeled "Load a New Page into a Frame" is clicked.

Related Searches:

References

  • Photo Credit Thinkstock Images/Comstock/Getty Images

Comments

Related Ads

Featured