弹出窗口返回值 [英] Popup window return value

查看:74
本文介绍了弹出窗口返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以帮助我解决这个问题。

I hope someone may be kind enough to help me with this issue.

我想要做什么我将一个值从弹出窗口返回到父窗口使用javascript启动它。

What I am trying to do I return a value from a popup window into the parent window that launched it using javascript.

我试过的是打电话(在各种网站上阅读)

What I have tried is calling (as read on various websites)

window.opener.document.forms[0].textField.value = 'value'

虽然这不会产生任何错误但它不会改变字段值。

but while this does not produce any errors it does not change the field value.

我试过在网上搜索解决方案但是那里由于许多网站都与谷歌上的弹出返回值相关,结果可追溯到2000年,许多人似乎互相冲突,所以我有点困惑。

I have tried searching on the net for a solution to this but there as so many sites relating to 'pop up return value' on google, results dating back to 2000, many seem to conflict each other so I am somewhat confused.

理想情况是什么我更愿意做的是让弹出窗口等待做出决定(是或否),并且从父窗口返回到调用函数的真值或假值。作为这个的原因,是我有一个表单使用onsubmit来调用javascript函数来确认天气继续没有。我正在使用一个对话框来返回一个真正的假值,但现在尝试弹出一个,这样我就可以包含图像和各种其他信息。

Ideally what I would prefer to do is have the pop up window wait for a decision to be made (either yes or no), and have a true or false value return to the calling function from the parent window. As the reason for this, is that I have a form the uses onsubmit to call a javascript function to confirm weather to continue on not. I was using a dialog to return a true false value, but now trying to do it with a pop up so I can include images and various other information.

希望我有解释得这么好,有人可以帮我解决。

Hopefully I have explained this well enough and someone can help me with a solution.

感谢您的时间。

推荐答案

您可以从弹出窗口引用打开弹出窗口的窗口...在此示例中,弹出窗口中的某些内容调用此函数(存在于弹出窗口中)传入val。 ..

You can reference the window that opened the popup from the popup... In this example, something on the popup window calls this function (which exists on the popup window) passing in the "val"...

 <script language="javascript">
    function GetRowValue(val)
    {
        // hardcoded value used to minimize the code.
        // ControlID can instead be passed as query string to the popup window
        window.opener.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value = val;
        window.close();

    }

    </script>

这篇关于弹出窗口返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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