javascript windows "Yes/No" asking twice?
I am using below code for javascript window "Yes/No". It is firing twice. Is there any way I can 开发者_C百科avoid this? Or use any other code?. I need this code behind.
Response.Write("<script language='javascript'> { self.close() }</script>");
It looks like you're using Response.Write
where it would end up at the bottom of the page, like this:
</html>
<script language='javascript'> { self.close() }</script>
This will give all sorts of funky behavior, instead use ClientScript.RegisterStartupScript
, like this:
ClientScript.RegisterStartupScript(typeof(Page),"close","window.close();",true);
If you were using update panels (which doesn't seem the case from Response.Write()
) you would use the similar ScriptManager.RegisterStartupScript()
method.
精彩评论