[英]I want to return true if the button is clicked and also close the window onclick using JavaScript
如果要單擊按鈕,我想返回true並使用JAVASCRIPT關閉窗口onclick我正在使用此代碼返回true並立即關閉窗口
的JavaScript
function out()
{
return true;
window.close();
}
的HTML
form name="remove" action="" method="post">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="text-align:center">
<tr height="30px" id="rem">
<td><input type="submit" name="ok" value="Remove Access" onClick="out();" /></td>
</tr>
</table>
</form>
但窗口沒有關閉。 但是它返回true。 我在這里想念什么。
我正在更新按鈕單擊時的數據庫值(如果它返回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;
}
“返回”后的指令不執行。
當您返回時,其余功能將被取消:
function out()
{
window.close();
return true;
}
但是window.close()
會嘗試關閉當前窗口。 而且返回將永遠不會被使用。 因為窗口是關閉的。
請參閱以下示例:
function test() {
alert(1);
return true;
alert(2);
}
alert(2)
未執行,因為您已經返回:
function test() {
alert(1);
alert(2);
return true;
}
現在顯示兩個警報。
試試這個:
function out()
{
window.close();
return true;
}
return語句使函數退出,因此不會執行return之后的任何其他代碼。
如果您已經打開了一個彈出窗口,最好在“父”頁面中添加一個隱藏字段,並在out()上更新其值
功能out()
{
parent.document.getElementById('hidField').value = "true";
window.close();
}
現在,在父頁面中,您可以獲得隱藏字段的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.