0
对象在Internet Explorer我的代码工作得很好,但我在Mac上使用Safari,这让我那个错误。这是我的代码:类型错误:“未定义”不是(评估“window.frames [‘内容’] document.location。”)
<!DOCTYPE html>
<html>
<head>
<title>The Me Project</title>
<link href="me.css" rel="stylesheet" type="text/css" href="me.css" />
<script type="text/javascript">
function page(setter)
{
if (setter=="home")
{
window.frames["content"].document.location.href = "home.html";
}
else if (setter=="birth")
{
window.frames["content"].document.location.href = "birth.html";
}
else if (setter=="cool")
{
window.frames["content"].document.location.href = "cool.html";
}
else if (setter=="family")
{
window.frames["content"].document.location.href = "family.html";
}
else
{
window.frames["content"].document.location.href = "home.html";
}
}
</script>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<div id="header">
<div id="nav">
<h1>Parth's Me Project</h1>
<ul>
<li><a onclick="page('home')">Home</a></li>
<li><a onclick="page('birth')">Birth Year</a></li>
<li><a onclick="page('cool')">Cool Things</a></li>
<li><a onclick="page('family')">My Family</a></li>
</ul>
</div>
</div>
<div id="main">
<iframe src="home.html" name="content" id="content" seamless height="1000" frameborder="0"/>
</div>
<frame>
</body>
</html>
如果需要其他页面,只是告诉我,我想保持相同的页眉和导航栏,所以我用在底部的iframe。
请提出问题。 –
你会得到“不安全的JavaScript尝试访问框架与URL”错误? – MikeB
我在Safari或Chrome中没有遇到这个错误。 [小提琴](http://jsfiddle.net/barmar/cqjJZ/) – Barmar