open.aspx
  function jsCloseWindow()
    {
    //alert(111);
    window.opener = null ;
    window.close();
    }
function jsClose()
{}
onbeforeunload="jsClose()"有个关闭Button Click事件里面
 ClientScript.RegisterStartupScript(this.GetType(), "key0fds07", "<script>jsCloseWindow()</script>");用Button关闭页面的时候提示 找不到jsClose()
点页面那个叉号关闭的时候正常!
请问为什么?

解决方案 »

  1.   

    把function jsClose()
    {}写在<head>中看看?
      

  2.   

    我的jsClose()
    是写在</html>后面的
      

  3.   

    就是
    onbeforeunload="jsClose()"
    这个在正常关闭的时候不报错
    在前台用 jsCloseWindow关闭也不报错但是在后面用RegisterStartupScript报错
      

  4.   

    是不是少了冒号?
    "<script>jsCloseWindow();</script>"
      

  5.   

    脚本写在<head></head>中应该就可以了.
      

  6.   

    冒号不是吧~
    错误是jsClose()找不到
    不是jsCloseWindow()找不到
    但是调用jsCloseWindow()关闭,所以肯定会调用jsClose函数
      

  7.   

    ForError.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ForError.aspx.cs" Inherits="ForError" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
     <script>
        function jsCloseWindow()
        {
        //alert(111);
        window.opener = null ;
        window.close();
        }
        function jsClose()
        {
        }
        }
        </script>
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
      

  8.   

    cs
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class ForError : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "key0fds07", "<script>jsCloseWindow();</script>");
        }
    }
      

  9.   

    function jsClose()
        {
        }
        }
    这里多写了一个 }
      

  10.   

    这个我测了一下
    好像没有问题
    不过我的jsClose()里面是有代码的
    估计是js代码里面错误 function jsClose()
        {
         //alert(111);
         createXMLHttpRequest(); 
              var oId=<%=theID%>;
              //alert(oId);
              createXMLHttpRequest(); 
              var webFileUrl = "DealStatus.aspx?id=" + oId;
              var result = "";
              xmlHttp.open("POST", webFileUrl, false);
              xmlHttp.send("");
              result = xmlHttp.responseText; 
              //debugger ;
              if(result != "")
              {
                   //debugger ;
                   if(result =='ok')
                   {
                   //debugger ;
                   //window.opener.parent.location.href=window.opener.parent.location.href;
                   }
              }
        }
      

  11.   

    cpp2017(慕白兄) 
    我还在调
    不过估计是你讲的位置问题
    先谢谢
      

  12.   

    肯定出现了某个地方的js语法错误,导致 jsClose() 方法无法被浏览器正常解释
      

  13.   

    搞定   谢谢 慕白
    还有 晓风 
    ustb viena