In my JavaScript function, I have the following code:
function CloseWindow() {
alert("I am firing"); // window.close();
}
I attempted to call this function from the code behind button click event using the following code snippet:
Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:CloseWindow();", True)
However, the function does not display the alert message as expected. Interestingly, when I call the same function from OnClientClick, it works properly.
OnClientClick="javascript:();"
What could be causing this issue? Please feel free to ask for further clarification if needed.
Contributed by
<script type="text/javascript" language="javascript">
function CloseWindow() {
alert("I am firing");
// window.close();<br>
}
function chkLength(evt, len) {
var str = document.getElementById(evt.id);
if (str.value.length < len)
return true;
else
return false;
}
</script>