使用window.opener在IE中的JavaScript问题 [英] JavaScript issue in IE with window.opener

查看:1496
本文介绍了使用window.opener在IE中的JavaScript问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下JavaScript检查弹出页面是否仍处于打开状态。

I am trying to use the following JavaScript to check if a popup page is still open.

父页面(打开弹出窗口的调用页面)已打开,但是代码继续失败。我从一个aspx弹出页面调用它,该页面在另一个母版页中有一个母版页。因此,最终调用此脚本的单击事件是内容占位符中Gridview中的编辑链接,该占位符位于最上面的主页面内容占位符中,不确定它是否与它有任何关系。该脚本触发,但它没有看到父页面处于打开状态而未关闭。

The parent page (calling page to open popup) is open but this code continues to fail. I am calling it from an aspx popup page that has a masterpage inside another masterpage. So the click event that eventually calls this script is an Edit Link in a Gridview in a content Placeholder which is in the upper most master page content Placeholder, not sure if that has anything to do with it. The script fires but it does not see the parent page as open and not closed.

if (window.opener != null && !window.opener.closed) { 
    alert(window.opener); 
    var val = window.opener.parentFunc(a); 
    alert(a); 
} 

这是IE唯一的问题,Firefox可以识别 window.opener 页面。尝试IE的多个版本都有问题,但Firefox和Opera工作正常。

This is an IE only problem, Firefox can identify the window.opener page. Tried multiple versions of IE all had issues, Firefox and Opera work though.

我实际上使用了这个警告声明....

I actually used this alert statement....

alert(window.opener);

在IE中返回未定义。

In Firefox返回了ObjectWindow。

In Firefox returned ObjectWindow.

推荐答案

我通过从VB.net发送脚本来实现这一点....

I got this to work by sending the script from VB.net like this....

Dim BrowserSettings As String = "status=no,toolbar=no, scrollbars =yes,menubar=no,location=no,resizable=no," & "titlebar=no, addressbar=no, width=650 ,height=800"
Dim URL As String = "testNewPage.aspx"
Dim scriptText1 As String = ("<script>javascript: var w = window.open('" & URL & "','_blank','" & BrowserSettings & "'); </script>")
ScriptManager.RegisterStartupScript(Me, GetType(Page), "ClientScript1", scriptText1, False)here

这不是我想要的,但是它似乎工作,除了现在弹出页面不在顶部。需要弄清楚那部分。

This isn't exactly what I wanted, but it seems to be working except now the popup page is not on top. Need to figure that part out.

我一直试图应用焦点,似乎没有用。
另外,尝试了一个modaless弹出窗口,但有效但我丢失了对打开窗口的引用。

I have been trying to apply focus, doesn't seem to work. Also, tried a modaless popup, that works but I lose the reference to the open window then.

这篇关于使用window.opener在IE中的JavaScript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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