在ASP中
function SayErr(err_str,str1)
response.write "<script language=javascript>"
if err_str<>"" then
response.write "alert('"&err_str&"');"
end if
if trim(str1)="" then
response.write "if(history.length==0){opener='kingneed';window.close()}else{history.back();}</script>"
else
response.write "location='"&str1&"';</script>"
end if
response.end
end function
是可以运行的
但是我在.NET中改成这样
function SayErr(err_str,str1)
response.write("<script language=javascript>")
if err_str<>"" then
response.write("alert('"&err_str&"');")
end if
if trim(str1)="" then
response.write("if(history.length==0){opener='kingneed';window.close()}else{history.back();}</script>")
else
response.write("location='"&str1&"';</script>")
end if
response.end
end function
提示我出错:Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed
不知道这句是什么意思,请高手帮帮忙,教教我怎么用这段程序,谢谢!

解决方案 »

  1.   

    {opener='kingneed';window.close()}else{history.back();}
    是这个把,你应该试着去进行字符的转义
      

  2.   

    vb_vs(我是一只紧张的小星星^_^)
    谢谢你的参与,但问题的重点不是这点,而是
    <script runat=server>
    function SayErr(err_str as string,str1 as string)
    response.write("<script language=javascript>")
    if err_str<>"" then
    response.write("alert('"&ctype(err_str,string)&"');")
    end if
    if trim(str1)="" then
    response.write("if(history.length==0){opener='kingneed';window.close()}else{history.back();}")
    else
    response.write("location='"&ctype(str1,string)&"';")
    end if
    print("</script >")
    response.end
    end function
    </script>
    这种形式,在<script>之中包含了<script>标签,所以会出错。
    如果使用其它的</script &gt;这种样式的,根本起不了javascript的作用!
    谢谢 。
      

  3.   

    <script runat=server>
    function SayErr(err_str as string,str1 as string)
    response.write("<script language=javascript>")
    if err_str<>"" then
    response.write("alert('"&ctype(err_str,string)&"');")
    end if
    if trim(str1)="" then
    response.write("if(history.length==0){opener='kingneed';window.close()}else{history.back();}")
    else
    response.write("location='"&ctype(str1,string)&"';")
    end if
    print("</script"&">")
    response.end
    end function
    </script>
    还要咱家自己想出来,头疼!