window.opener无法正常工作 [英] window.opener not working

查看:105
本文介绍了window.opener无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我做了一个window.opener返回一个值到父页面.我使用window.showModalDialog()打开了弹出窗口.我知道它进入了我的javascript函数,因为我发出了警报,警报弹出了. window.opener不会将值发送回我分配的文本框,它甚至都没有关闭.这是我的JavaScript代码(这是嵌入式JavaScript):

Hi,

I made a window.opener to return a value to the parent page. I used window.showModalDialog() to open the pop up. I know that it goes to my javascript function since I put an alert and the alert pops up. The window.opener does not send the value back to the textbox that I assigned and it does not even close. Here is my javascript code (this is an inline javascript):

<script language="javascript" type="text/javascript">

            function SelectAndClose()
            {
                txtValue = document.getElementById('_browseTextBox').value;

                //window.returnValue = txtValue.value;
                window.opener.document.getElementById('txtRaw').value = txtValue;
                self.close;
                alert("Hello");
                //return false;
            }

        </script>



这是我对此javascript的函数调用:



Here is my function call to this javascript:

<asp:Button ID="_selectButton" Text= "OK" runat="server" Width="138px" OnClientClick="javascript:SelectAndClose()"/>



谢谢!



Thanks!

推荐答案

您可能误解了属性window.opener.如果您显示的内容放在某个HTML页面中,并且使用某些URI(HTTP/HTTPs URL的文件名,无关紧要)通过浏览器打开此页面,则显然打开器为null.没有打开程序",可能是打开浏览器窗口的其他窗口".

要了解它,请参阅:
http://www.w3schools.com/jsref/prop_win_opener.asp [
You probably misunderstood the property window.opener. If the content you show is placed in some HTML page, and you open this page with a browser using some URI (file name of HTTP/HTTPs URL, does not matter), it is apparent that the opener is null. There is no an "opener", which could be some "other window" which opened your browser window.

To understand it, please see:
http://www.w3schools.com/jsref/prop_win_opener.asp[^].

—SA


这篇关于window.opener无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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