在服务器端写的两种方法
ClientScript.RegisterStartupScript(ClientScript.GetType(), "MyScript", "sayhello();", true);
这种写法在客户端写好sayhello函数然后调用Response.Write("<script>alert('hello!')");
这种写法直接写到客户端脚本两种写法显示消息的时候,后面屏幕都是白的,好像是因为页面还没有加载。要在服务器端调用alert,有什么办法可以避免这种情况?
ClientScript.RegisterStartupScript(ClientScript.GetType(), "MyScript", "sayhello();", true);
这种写法在客户端写好sayhello函数然后调用Response.Write("<script>alert('hello!')");
这种写法直接写到客户端脚本两种写法显示消息的时候,后面屏幕都是白的,好像是因为页面还没有加载。要在服务器端调用alert,有什么办法可以避免这种情况?
后面屏幕都是白的
可能的页面结构不是很好,如嵌套的是整个table、或者页面内容加载慢等,你可以进行延迟下ClientScript.RegisterStartupScript(ClientScript.GetType(), "MyScript", "setTimeout('sayhello()',3000)", true);