开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜