![]() |
#2
阳光上的桥2023-06-02 13:26
|
只有本站会员才能查看附件,请 登录
index.html页面:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>框架的属性</title>
</head>
<frameset id="myset" cols="150px, *">
<frame src="nav.html" name="leftFrame" scrolling="yes" noresize="noresize" />
<frameset rows="40px, *">
<frame src="tool.html" name="topFrame" scrolling="no" noresize="noresize" />
<frame src="content.html" name="mainFrame" scrolling="auto" noresize="noresize" />
</frameset>
</frameset>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>框架的属性</title>
</head>
<frameset id="myset" cols="150px, *">
<frame src="nav.html" name="leftFrame" scrolling="yes" noresize="noresize" />
<frameset rows="40px, *">
<frame src="tool.html" name="topFrame" scrolling="no" noresize="noresize" />
<frame src="content.html" name="mainFrame" scrolling="auto" noresize="noresize" />
</frameset>
</frameset>
</html>
tool.html页面:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>工具框架</title>
<script>
function hideOrDisplayNavFrame()
{
var frameset = window.self.top.document.getElementById("myset");
var button = window.self.document.getElementById("mybtn");
if (button.value == "隐藏导航栏")
{
frameset.cols = "0px, *";
button.value = "显示导航栏";
}
else
{
frameset.cols = "150px, *";
button.value = "隐藏导航栏";
}
}
</script>
</head>
<body>
<input id="mybtn" type="button" value="隐藏导航栏" onclick="hideOrDisplayNavFrame();" />
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>工具框架</title>
<script>
function hideOrDisplayNavFrame()
{
var frameset = window.self.top.document.getElementById("myset");
var button = window.self.document.getElementById("mybtn");
if (button.value == "隐藏导航栏")
{
frameset.cols = "0px, *";
button.value = "显示导航栏";
}
else
{
frameset.cols = "150px, *";
button.value = "隐藏导航栏";
}
}
</script>
</head>
<body>
<input id="mybtn" type="button" value="隐藏导航栏" onclick="hideOrDisplayNavFrame();" />
</body>
</html>
运行时总提示下面错误:
ol.html:9 Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
at hideOrDisplayNavFrame (file:///C:/Users/admin/Documents/%E6%9C%AA%E5%91%BD%E5%90%8D%E7%AB%99%E7%82%B9%205/tool.html:9:44)
at HTMLInputElement.onclick (file:///C:/Users/admin/Documents/%E6%9C%AA%E5%91%BD%E5%90%8D%E7%AB%99%E7%82%B9%205/tool.html:25:88)
at hideOrDisplayNavFrame (file:///C:/Users/admin/Documents/%E6%9C%AA%E5%91%BD%E5%90%8D%E7%AB%99%E7%82%B9%205/tool.html:9:44)
at HTMLInputElement.onclick (file:///C:/Users/admin/Documents/%E6%9C%AA%E5%91%BD%E5%90%8D%E7%AB%99%E7%82%B9%205/tool.html:25:88)
[此贴子已经被作者于2023-6-1 10:28编辑过]