【问题标题】:Close pop-up from code behind从后面的代码关闭弹出窗口
【发布时间】:2016-05-12 13:38:14
【问题描述】:

我有两个网站(都在我的控制范围内)

站点 1 - 在站点 2 上打开一个弹出窗口。要在站点 2 上打开弹出窗口,我有以下内容

Dim strPopup As String = "<script language='javascript' ID='script1'>" + "window.open('" & http://site2.com/customer.aspx" & ",'pop', 'top=90, left=200, width=1000, height=800, dependant=no, location=0, alwaysRaised=no, menubar=no, resizeable=no, scrollbars=no, toolbar=no, status=no, center=yes')" + "</script>"

ScriptManager.RegisterStartupScript(DirectCast(HttpContext.Current.Handler, Page), GetType(Page), "Script1", strPopup, False)

注意:上面代码中的'pop'是我理解的表单名称。

到目前为止,这按预期工作。

Site 2 从上方显示弹出窗口,上面有一个按钮。我想关闭上面打开的弹出窗口/窗口,因此调整了上面的脚本并将其添加到站点 2 后面代码中的按钮事件中

Dim strPopup As String = "<script language='javascript' ID='script1'>" + "window.close" + "</script>"

ScriptManager.RegisterStartupScript(DirectCast(HttpContext.Current.Handler, Page), GetType(Page), "Script1", strPopup, False)

但这不起作用。我试过了

pop.close(pop 是我发布的第一个代码上的表单名称)

我对如何在后面的代码中的按钮事件中关闭打开的窗口有点迷茫(请注意在弹出窗口中,用户在单击此按钮时正在保存数据,因此我的想法是关闭按钮一次他们点击保存按钮)

【问题讨论】:

  • 您是否尝试将window.close 替换为window.close()(带圆括号)?
  • 是的,做到了!随意添加它作为答案,我会接受这个作为答案。

标签: javascript asp.net vb.net


【解决方案1】:

window.close 是一个函数。您应该使用window.close()(带圆括号)而不是window.close

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    相关资源
    最近更新 更多