简体   繁体   English

如何在子页面中访问父窗口元素

[英]How to access Parent Window Elements in Child Page

I have a Main page(Parent) and one pop up page(Child Page) on it, i want to pass an XML string from Parent page to Child page. 我有一个主页(父页面)和一个弹出页面(子页面),我想将XML字符串从父页面传递到子页面。 when i tried to do it with query string i got this following Error. 当我尝试使用查询字符串执行此操作时,出现以下错误。

"A Potentially dangerous Request.QueryString value was detected from the client" “从客户端检测到潜在危险的Request.QueryString值”

Can any one knows others ways to pass data from Parent to child page. 任何人都可以知道其他将数据从父页面传递到子页面的方法。

Thanks in Advance Nitesh katare 在此先感谢Nitesh katare

If all you want is to pass a string, why don't you declare a global function in the parent window? 如果只需要传递一个字符串,为什么不在父窗口中声明一个全局函数呢?

PARENT PAGE
<script>
var my_string = '';
function set_string( x ) { 
  my_string = x;
}
</script>

Then calling the function from the child page is simple: 然后从子页面调用函数很简单:

CHILD PAGE
<script>
parent.set_string( "whatever" );
</script>

在弹出窗口中,您可以致电

window.opener.<your function>(<the xml>)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM