Latest web development tutorials

HTML DOM Frameset cols attribute

Frameset Object Reference Frameset objects

Definition and Usage

cols property sets or returns the focus frame number and size of the columns.

Or the percentage of a comma-delimited list of pixels defines the number of columns and width.

grammar

framesetObject.cols=values

cols attribute may be one or more of the following values:

描述
pixels 以像素为单位指定列的大小 (如: "100px" 或者 "100")
% 以百分比指定列的大小(如:"50%")
* 剩余可用的列空间


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support cols attribute.


Examples

In our example, first create a frameset with two columns of the HTML document. Each column is set to 50% of the browser window:

<Html>
<Frameset id = "main" cols = "50%, 50%">
<Frame src = "frame_cols.htm">
<Frame src = "frame_a.htm">
</ Frameset>
</ Html>

"Frame_cols.htm" Source code is as follows:

Examples

<html>
<head>
<script>
function changeCols()
{
    parent.document.getElementById("main").cols="30%,70%"
}
function restoreCols()
{
    parent.document.getElementById("main").cols="50%,50%"
}
</script>
</head>
<body>

<input type="button" onclick="changeCols()" value="Change column size">
<input type="button" onclick="restoreCols()" value="Restore column size">

</body>
</html>

try it"


Frameset Object Reference Frameset objects