使用window.location.href时出错

时间:2015-09-21 00:59:09

标签: javascript

我正在阅读这本书:开始使用Javascript并使用Chrome作为我的浏览器。

行window.location.href用于以下代码:

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Ch 8</title>
<script type = "text/javascript">
function window_onload()
{
    alert("The name of the lower frame's window object is "
    + window.name);
    alert("The location of the lowerWindow's parent is "
    + window.parent.location.href);
}
</script>

    

        下框架     

父母是:

<!DOCTYPE html PUBLIC *-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Ch. 8</title>
</head>
<frameset row = "50%, *" id = "topWindow">
    <frame name = "upperWindow" src = "ch08_examp1_upper.htm" />
    <frame name = "lowerWindow" src = "ch08_examp1_lower.htm" />
</frameset>
</hmtl>

这会引发以下错误: “阻止具有原点”null“的帧访问具有原点”null“的帧。协议,域和端口必须匹配。”

该文件与父文件保存在同一目录中。我所做的事情有什么明显的错误吗?

0 个答案:

没有答案