Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果单击了按钮,我希望返回true,并使用JavaScript在单击时关闭窗口_Javascript_Html_Asp Classic_Vbscript - Fatal编程技术网

如果单击了按钮,我希望返回true,并使用JavaScript在单击时关闭窗口

如果单击了按钮,我希望返回true,并使用JavaScript在单击时关闭窗口,javascript,html,asp-classic,vbscript,Javascript,Html,Asp Classic,Vbscript,如果单击了按钮,我希望返回true,并使用JAVASCRIPT在单击时关闭窗口 我使用此代码返回true并立即关闭窗口 JavaScript function out() { return true; window.close(); } HTML formname=“remove”action=“”method=“post”> 但是窗户没有关上。但它又回到了现实。我错过了什么 我正在更新按钮上的数据库值,如果返回true,请单击,即单击 <% if requ

如果单击了按钮,我希望返回true,并使用JAVASCRIPT在单击时关闭窗口 我使用此代码返回true并立即关闭窗口

JavaScript

function out()
{
    return true;
    window.close();


}
HTML

formname=“remove”action=“”method=“post”>
但是窗户没有关上。但它又回到了现实。我错过了什么

我正在更新按钮上的数据库值,如果返回true,请单击,即单击

<%
    if request.form("ok") <> "" then
        sql1 = "select * from folder_access where srno = '"&request.QueryString("srno")&"'"
        rs1.open sql1, con, 1, 2
            rs1("folder_removed") = "Remove Access"
            session("ok") = "Remove Access"
        rs1.update

        rs1.close
    end if

%>

之类的

function out()
{
    window.close();
    return true;
}

“return”之后的指令不会执行。

当您返回时,函数的其余部分将被取消:

function out()
{
    window.close();
    return true;
}
但是
window.close()
将尝试关闭当前窗口。而且回报永远不会被使用。因为窗户是关着的


请参见此示例:

function test() {
    alert(1);
    return true;
    alert(2);
}
警报(2)
未执行,因为您已返回:

function test() {
    alert(1);
    alert(2);
    return true;
}
现在显示两个警报。

试试这一个:

function out()
{    
    window.close();
    return true;
}

return语句使函数退出,因此返回后的任何其他代码都不会执行。

如果您打开了一个弹出窗口,最好在父页面中添加一个隐藏字段,并在out()上更新其值

函数输出()

{

}


现在,在父页面中,您可以获得隐藏字段的值。

因为您已经从函数返回,所以window.close()将不会执行。这不是JAVSCRIPT。我想你指的是JavaScript。关闭窗口的返回值有什么用?很抱歉,如果我太厚了,那么您打算如何处理返回值?我正在使用按钮cilck的值更新数据库文件。您认为它为什么不会返回true?您认为它不返回true是什么意思?它确实返回true,但在关闭的窗口中。如果要将“true”值传递给另一个窗口,则必须以不同的方式进行传递。
function out()
{    
    window.close();
    return true;
}
parent.document.getElementById('hidField').value = "true";
window.close();