两个页面,1.aspx 和 2.aspx,1中用js连接到2,传递不同的参数,比如
2.aspx?type = insert
2.aspx?type = update
到一个隐藏域type,如果type=update,那么2中的一文本框id只能是只读的。
该怎么实现?

解决方案 »

  1.   

    <script for="window" event="onload">
    var strFilePath = window.location.search;
    if(strFilePath != "" && strFilePath != null)
    {
        var index = strFilePath.indexOf("type=update");
        if(index > -1)
        {
            document.getElementById("aaaa").readonly = true;
        }
    }
    </script>
      

  2.   

    function fnLoad()
    {
    var strFilePath = window.location.search;
    if(strFilePath != "" && strFilePath != null)
    {
    var index = strFilePath.indexOf("type=update");
    if(index > -1)
    {
    document.getElementById("aaaa").readonly = true;
    }
    }
    }if(window.addEventListener)
    {
    window.addEventListener("load", fnLoad, false);
    }
    else
    {
    window.attachEvent("onload", fnLoad);
    }