gpt4 book ai didi

javascript - OnClientClick 在 IE 中不起作用,但在 Chrome 中起作用

转载 作者:行者123 更新时间:2023-11-28 10:16:25 25 4
gpt4 key购买 nike

ASP.net 页面

        <script type="text/javascript" language="javascript">
function show_confirm() {
var r = confirm("Are you sure you want to Save this Transaction");
if (r == true) {
$('#<%=btnConfirm.ClientID%>').click();
}
else {
}
}
</script>

<asp:Content ID="detailContent" ContentPlaceHolderID="mainContentPlaceholder"
runat="server">
<asp:LinkButton ID="LinkButton1" runat="server"
CssClass="primary positive big button" OnClientClick="return show_confirm();return false"><span class="check icon"></span>Save Transaction</asp:LinkButton>
<asp:Button ID="btnConfirm" runat="server" Style="display: none;" onclick="btnConfirm_Click"/>
</content>

如果用户在弹出消息框中单击"is",这将触发 btnConfirm 单击。

在 IE 上查看源代码

<a onclick="return show_confirm();return false;" id="ctl00_mainContentPlaceholder_LinkButton1" class="primary positive big button" href="javascript:__doPostBack('ctl00$mainContentPlaceholder$LinkButton1','')">
<span class="check icon"></span>Save Transaction</a>
<input type="submit" name="ctl00$mainContentPlaceholder$btnConfirm" value="" id="ctl00_mainContentPlaceholder_btnConfirm" style="display: none;" />

谢谢您的问候

最佳答案

show_confirm() 函数不返回 bool 值。它应该返回一个值才能正常工作。

为什么不简单地像下面这样做,它会做你正在寻找的事情。

<asp:LinkButton ID="LinkButton1" runat="server"
CssClass="primary positive big button" OnClick="LinkButton1_Click"
OnClientClick="return confirm('Are you sure you want to Save this Transaction');">
<span class="check icon"></span>Save Transaction </asp:LinkButton>

关于javascript - OnClientClick 在 IE 中不起作用,但在 Chrome 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6515673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com