aspx页面里定义的javascript 变量,通过什么方式能传递到htm页面的Javascript中,ashx文件里如何或得htm 里的Javascript变量

解决方案 »

  1.   

    从后台传到页面的js代码用eval转换成js对象即可
    如后台的 String s = "var date = new Date();";
    js中只需要 eval(s); alert(date);即可
    js前台传递数据用表单和url传递即可,window.location = "url?date=" + new Date()
      

  2.   

    .cs页面 
    string a="ok";
     Page.ClientScript.RegisterClientScriptBlock(typeof(string), "wanjiafengcaihtml", "<script>aaa("+a+")</script>");.html页面,注意script代码放在head里面
    <script>
    function aaa(txt)
    {
    alert(txt);
    }
    </script>
      

  3.   

    不同页面直接的javascript变量传递