JavaScript Tutorial/HTML Tags/frameset

Материал из Web эксперт
Перейти к: навигация, поиск

Change frame location(URL)

<head>
<script language="JavaScript" type = "text/javascript">
<!--
function changeLocation()
{
    parent.frames[1].location = document.form1.NewURL.value;
}
//-->
</script>
</head>
<body>
<title>Specify URL</title>
</head>
<body>
<form name="form1">
   <input type="text" name="NewURL" size="50">
   <input type="button" value="Change URL" name="URLButton" onClick = "changeLocation()"></p>
</form>
</body>


Change two frames in a frame set

index.htm



<HTML>
<FRAMESET rows="33%,*,33%">
<FRAME name="t_frame" src="1.html">
<FRAME name="m_frame" src="2.html">
<FRAME name="b_frame" src="3.html">
</FRAMESET>
</HTML>


Nested framesets

index.htm



<head>
        <title>Frameset Example</title>
    </head>
    <frameset rows="100,*">
        <frame src="frame.htm" name="topFrame" />
        <frameset cols="50%,50%">
            <frame src="anotherframe.htm" name="leftFrame" />
            <frame src="yetanotherframe.htm" name="rightFrame" />
        </frameset>
    </frameset>


Output a frameset through document.write

<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--
var frame_URL;
if (location.search)
{
    frame_URL = location.search.substring(1);
}
else {
     frame_URL = "http://www.wbex.ru";
}
{
 document.write("<frameset rows = "20%, 80%">")
 document.write("  <frame src="http://www.wbex.ru">")
 document.write("<frame src="" + frame_URL + "">")
 document.write("  </frameset>")
}
//-->
</script>
</head>
<body>
</body>
</html>


Reference element in frameset

index.html



<HEAD>
</HEAD>
<FRAMESET cols="150,*">
<FRAME name="left_side" src="1.html">
<FRAME name="right_side" src="2.html">
</FRAMESET>


Reference the parent frame

index.htm



<head>
        <title>Frameset Example</title>
    </head>
    <frameset rows="100,*">
        <frame src="frame.htm" name="topFrame" />
        <frameset cols="50%,50%">
            <frame src="anotherframe.htm" name="leftFrame" />
            <frame src="anotherframeset.htm" name="rightFrame" />
        </frameset>
    </frameset>


Reference the top frame

index.html



<html>
    <head>
        <title>Frameset Example</title>
    </head>
    <frameset cols="100,*">
        <frame src="red.htm" name="redFrame" />
        <frame src="blue.htm" name="blueFrame" />
    </frameset>
</html>