我在aspx页面上这样插入了一段脚本:
<script src=js/JScript1.js></script>。Script1.js文件如下:function showInfo()//展示div
{
    document.getElementById("info").style.display="block";
    document.getElementById("butShow").disabled=true;
}function close()//关闭
{
    document.getElementById("info").style.display="none";
    document.getElementById("butShow").disabled=false;
}function nowClear()//清空信息
{
    document.getElementById("txtTitle").value="";
    document.getElementById("txtName").value="";
    document.getElementById("txtContent").value="";
    document.getElementById("txtFrom").value="";
}
function save()//提交信息
{
    //验证信息完整
    if(document.getElementById("txtTitle").value=="")
    {
        alert("请输入标题!");
        return;    
    }
    if(document.getElementById("txtContent").value=="")
    {
        alert("您还没有输入内容。");
        return;    
    }
    /*
    
    在这里添加保存信息的代码
    
    */
    nowClear();//清空信息
    close();//关闭div
}最后出现2个问题,1.我的js脚本的一些函数执行完了程序却回发又调用page_load(),为什么?
2.几个alert弹出框为什么都不能正常的弹出中文?都是乱码。
请高手指点,问题解决马上给分。在线等。

解决方案 »

  1.   

    1.你调用js函数的控件看是不是服务器端控件
    2.需要设置一下web.config
    <globalization requestEncoding="gb2312" responseEncoding="gb2312"/>
    这样试试看行不?
      

  2.   

    第二个问题解决了,就是按照你说的差不多:    <globalization 
    culture="zh-CN"
                requestEncoding="gb2312" 
                responseEncoding="gb2312" 
       />可是第一个问题还没有,我把<script src=js/JScript1.js></script>放到<head></head>里面也不行。是不是因为我的调用的控件都放在form里面了?可是只能放在这里啊。
      

  3.   

    我用Response.Write("<script src=js/JScript1.js></script>");这样都不行!
      

  4.   

    你是如何调用函数的?用的什么控件调用?如果是NET控件,在函数中最后加入return false;
    调用时,用return save();等等
      

  5.   

    调用page load的话肯定是点击了服务器控件,在后面加上return false
    button.Attribute.Add("onclick","nowClear();return false;");
      

  6.   

    找到原因了,是因为我的按钮不小心写成了type="submit" 所以回发!
    谢谢2位!