ASP.NETページロードでの効果実装

3126 ワード

/// 
///        
/// 
public static void initJavascript()
{
        HttpContext.Current.Response.Write(" ");
        HttpContext.Current.Response.Write("var t_id = setInterval(animate,20);");
        HttpContext.Current.Response.Write("var pos=0;var dir=2;var len=0;");
        HttpContext.Current.Response.Write("function animate(){");
        HttpContext.Current.Response.Write("var elem = document.getElementById('progress');");
        HttpContext.Current.Response.Write("if(elem != null) {");
        HttpContext.Current.Response.Write("if (pos==0) len += dir;");
        HttpContext.Current.Response.Write("if (len>32 || pos>79) pos += dir;");
        HttpContext.Current.Response.Write("if (pos>79) len -= dir;");
        HttpContext.Current.Response.Write(" if (pos>79 && len==0) pos=0;");
        HttpContext.Current.Response.Write("elem.style.left = pos;");
        HttpContext.Current.Response.Write("elem.style.width = len;");
        HttpContext.Current.Response.Write("}}");
        HttpContext.Current.Response.Write("function remove_loading() {");
        HttpContext.Current.Response.Write(" this.clearInterval(t_id);");
        HttpContext.Current.Response.Write("var targelem = document.getElementById('loader_container');");
        HttpContext.Current.Response.Write("targelem.style.display='none';");
        HttpContext.Current.Response.Write("targelem.style.visibility='hidden';");
        HttpContext.Current.Response.Write("}");
        HttpContext.Current.Response.Write("");
        HttpContext.Current.Response.Write("");
        HttpContext.Current.Response.Write("
"); HttpContext.Current.Response.Write("
"); HttpContext.Current.Response.Write("
...
"); HttpContext.Current.Response.Write("
"); HttpContext.Current.Response.Write("
"); HttpContext.Current.Response.Flush(); }

2.Page_Loadメソッドで呼び出す
 protected void Page_Load(object sender, EventArgs e)
 { 
     initJavascript();
 }

3.フロントコール