JavaScript的window.parent问题 [英] javascript window.parent issue
问题描述
我是新来的Javascript和阅读相关的书籍相当长的一段时间后,我仍然感到困惑是什么意思,什么是window.parent的功能?鸭preciate如果有人能告诉我一些简单的样本,让我知道什么呢window.parent是什么意思?谢谢!
I am new to Javascript and after reading related books for quite some time, I am still confused what is the meaning and what is the function of window.parent? Appreciate if someone could show me some simple samples to let me know what does window.parent mean? Thanks!
下面是code我很困惑,它是由ASP.Net类写为响应客户端的一部分的Javascript code的一部分。我especiallt困惑什么手段window.parent。+ Taget +.location ='+网址。鸭preciate如果有人能说清楚。
Here is the code I am confused, and it is a part of Javascript code written by a ASP.Net class as a part of response to client side. I am especiallt confused about what means window.parent." + Taget + ".location = '" + url. Appreciate if anyone could make it clear.
HttpContext.Current.Response.Write("<script>window.parent." + Taget + ".location = '" + url + "?userID=" + userID + "';window.location='Title.aspx';</script>");
在此先感谢,
乔治
thanks in advance, George
推荐答案
window.parent
指的是一帧(或iframe的)母公司:
window.parent
refers to a frame's (or iframe's) parent:
<frameset cols="25%,75%">
<frame src="frame_a.aspx" name="frameA" />
<frame src="frame_b.aspx" name="frameB" />
</frameset>
在上面的例子中,如果 window.parent
在frame_a.aspx被执行,它会指向包含的&lt窗口;框架&GT;元素。
In the above example, if window.parent
were executed in frame_a.aspx, it would refer to the window containing the <frameset> element.
目标指的是一帧(按名称)或标准的目标:
Target refers to either a frame (by name) or a standard target:
-
_blank
- 新窗口 -
_parent
- 当前帧的父级 -
_top
- 最顶部的框架(整个浏览器窗口/标签)
_blank
- New window_parent
- Current frame's parent_top
- Top-most frame (entire browser window/tab)
_top
和 _parent
只是指不同的东西,如果你的框架是多个级别深度(例如,如果frame_a.htm包含在另一个框架或iframe)
_top
and _parent
only refer to different things if your frames are more than one level deep (eg. if frame_a.htm contained another frameset or iframe)
'window.parent。 +目标+'.location
正在改变帧的URL,包含在当前帧的父内,用可变psented名重$ P $ 目标
。 (我假设 taget
简直就是一个错字)。
'window.parent.' + target + '.location'
is changing the URL of a frame, contained within the current frame's parent, with the name represented by the variable target
. (I have assumed taget
is simply a typo).
在我上面的例子中,如果frame_a.aspx与目标
变量frameB执行你的例子code,它会改变该帧的东西的网址其他(不影响frameA)。
In my above example, if frame_a.aspx executed your example code with the target
variable "frameB", it would change the url of that frame to something else (without affecting frameA).
虽然你没有提到它,它可能使用的是 window.open
,并试图打开它的窗口中更改位置。在这种情况下,你正在寻找 window.opener
。
Although you haven't mentioned it, it's possible you are using window.open
and are trying to change the location on the window that opened it. In that case, you are looking for window.opener
.
这篇关于JavaScript的window.parent问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!