在所有情况下,屏幕如何识别其父级? [英] How can a screen identify its parent in all cases?

查看:74
本文介绍了在所有情况下,屏幕如何识别其父级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的情景:


屏幕A ===>屏幕B ===>屏幕C

\\

\\

V

屏幕C


这意味着有时屏幕A打开B打开C;其他时候屏幕A直接打开C而B不使用。


问题是:C如何知道谁打开它 - A或B?这对于后续处理非常重要。


我尝试将ID值从A传递到C,从B传递给C,这样C就可以知道它的父节点,但我总是遇到浏览器解释器的问题表明该路径的代码不是这个时间的父并没有属性。并且该错误导致处理停止。到目前为止,尝试/最终声明在绕过这个错误时对我没有用。


我真正需要的是能够捕获解释器识别的错误并让我安全地解除它以便继续处理。 />

如果Javascript中没有这样的能力,我需要一些新的想法如何做我想要的而不会产生这些处理错误。


感谢所有能提供帮助的人。

解决方案

为什么你不能只使用window.opener?这应该标识父窗口。



为什么你不能只使用window.opener?那应该标识父窗口。



我用'window.opener.document.formname.field.value"对于我正在使用的路径并且它工作正常。


但是相反情况下不活动的路径的相同代码是浏览器发出消息的路径没有属性。


屏幕C的两个路径都有代码(由A打开;也由B打开)。它是导致浏览器抱怨的非活动路径的代码。



屏幕C中包含两个路径的代码(由A打开;也由B打开。它是导致浏览器抱怨的非活动路径的代码。



啊,我明白你的意思了。


你可以用URL传递一个参数。如果它是服务器端页面,请使用GET参数处理,如果是HTML,请使用location.search来解析查询字符串,例如: "页面B等于1英寸。


Here is my scenario:

Screen A ===> Screen B ===> Screen C
\\
\\
V
Screen C

What this means is that sometimes Screen A opens B that opens C; other times Screen A opens C directly and B is not used.

The question is: How does C always know who opened it -- A or B? This is essential to know for later processing.

I have tried passing an ID value from A to C and from B to C so C can know its parent, but I always run into the problem of the browser interpreter stating that the code-of-the-path-that-is-not-the-parent-this-time "has no properties" and that error causes processing to stop. So far the "try/finally" statement has not worked for me in bypassing this error.

What I really need is the ability to catch an error the interpreter identifies and let me safely defuse it so that processing continues.

If there is no such ability in Javascript, I need some fresh ideas how to do what I want without generating these processing errors.

Thanks to all who can help.

解决方案

Why can''t you just use window.opener? That should identify the parent window.


Why can''t you just use window.opener? That should identify the parent window.

I do use "window.opener.document.formname.field.value" for the path I am using and it works fine.

But the same code for the path that is not active for the opposite scenario is the path that the browser issues the message of "has no properties".

Screen C has code in it for both paths (opened by A; also, opened by B). It is the code for the non-active path that causes the browser to complain.


Screen C has code in it for both paths (opened by A; also, opened by B). It is the code for the non-active path that causes the browser to complain.

Ah, I see what you mean.

You could pass a parameter with the URL. If it''s a server-side page, use GET parameter handling and if it''s HTML, use location.search to parse the query string, e.g. "?pageB=1".


这篇关于在所有情况下,屏幕如何识别其父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆