Geo*_*ge2 0 javascript asp.net window.location
我是Javascript的新手,在阅读相关书籍很长一段时间后,我仍然感到困惑,window.parent的含义是什么?感谢有人能给我看一些简单的样品让我知道window.parent是什么意思吗?谢谢!
这是我困惑的代码,它是ASP.Net类编写的Javascript代码的一部分,作为客户端响应的一部分.我特别想知道window.parent是什么意思."+ Taget +".location ='"+ url.感谢有人能说清楚.
HttpContext.Current.Response.Write("<script>window.parent." + Taget + ".location = '" + url + "?userID=" + userID + "';window.location='Title.aspx';</script>");
Run Code Online (Sandbox Code Playgroud)
乔治,提前谢谢
window.parent 是指一个框架(或iframe)的父母:
<frameset cols="25%,75%">
<frame src="frame_a.aspx" name="frameA" />
<frame src="frame_b.aspx" name="frameB" />
</frameset>
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,如果window.parent在frame_a.aspx中执行,则它将引用包含<frameset>元素的窗口.
目标是指框架(按名称)或标准目标:
_blank - 新窗户_parent - 当前帧的父级_top - 最顶层的框架(整个浏览器窗口/标签)_top_parent如果您的帧深度超过一级,则仅引用不同的内容(例如,如果frame_a.htm包含另一个框架集或iframe)
'window.parent.' + target + '.location'正在更改包含在当前帧的父级中的帧的URL,其名称由变量表示target.(我假设taget只是一个错字).
在上面的例子中,如果frame_a.aspx使用target变量"frameB" 执行了您的示例代码,它会将该帧的url更改为其他内容(不影响frameA).
虽然您没有提到它,但您可能正在使用window.open并且正在尝试更改打开它的窗口上的位置.在那种情况下,你正在寻找window.opener.