JS -- 我的记录

 

iframe 自适应高度 -- 兼容IE FF
<head runat="server">
<title>无标题页</title>
    <script type ="text/javascript" >
       
function iframeFitHeight(oIframe) 
        {
//Iframe窗口自适应高度 兼容IE6.0 FF2.0以上 
            try 
            { 
                
var oWin = oIframe.name ? window.frames[oIframe.name] : oIframe.contentWindow;  
                oIframe.style.height 
= oWin.document.body.scrollHeight + "px"
            } 
            
catch(e){} 
        } 
        //这个好像更好些
        function autoSetIframeHeight(myIframe) {
            var h = "";
            var f = $(myIframe).parent().css("height");
            if (f == "auto") {
                try {
                    if (myIframe.contentDocument && myIframe.contentDocument.body.offsetHeight) {
                        h = myIframe.contentDocument.body.offsetHeight + "px";
                    }
                    else if (myIframe.Document && myIframe.Document.body.scrollHeight) {
                        h = myIframe.Document.body.scrollHeight + "px";
                    }
                }
                catch (err) {
                    h = "450px";
                }
            }
            else {
                if (f.indexOf('px') >= 0)
                    h = f;
                else
                    h = f + "px"
            }
            myIframe.style.height = h;
        }
    
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
      
<table>
         
<tr style="height :200px; width :500px">
           
<td style="width:150px; background-color :Green"> abcd </td>
           <td style="width:350px; background-color :Silver">
             
<iframe src="sub.aspx" style="overflow:auto" scrolling ="no" onload="iframeFitHeight(this)" ></iframe>
           </td>
         </tr>
      </table>
    </div>
    </form>
</body>
 
 
另一方案: 
--------------------------------------------------------------
(问题: FF不会收缩)

function reinitIframe() {

    var iframe = document.getElementById("taskFrame");

    try {
        var height;

        if ($.browser.mozilla)
            height = iframe.contentWindow.document.body.offsetHeight + 'px';
        else
            height = iframe.contentWindow.document.body.scrollHeight + 'px';

        iframe.style.height = height;

    } catch (ex) { }

}

<iframe marginheight='0' frameborder='0' src="demo.aspx" 
style='width: 100%;' scrolling="no" id="taskFrame" name="taskFrame" onload ="reinitIframe()"></iframe>

 

 

 

弹窗确认提交 -- confirm prompt
// JS ******************************************

function CheckOut()
{
   
if(confirm('确定要结算吗?'))
   {
      
var d = prompt("请输入结算时间","2009/12/3");
      
if(d!=null)
      {  
         document.getElementById (
'hidCheckOutDate').value = d;  //使用隐藏控件储存提交的数据
         document.getElementById ('btnCheckOut').submit();       //使用此方法提交
      }
      
else
      {}    
   }
   
else
   {}   
//要这样写才不会提交!!!
}

//后台 ******************************************

this.btnCheckOut.Attributes.Add("onclick""CheckOut();return false;");  //要加return false;

protected 
void btnCheckOut_Click(object sender, EventArgs e)
{
   DateTime date 
= DateTime.Parse(this.hidCheckOutDate.Value);
}

 

 

ShowModalDialog & ShowModalLessDialog

 

document.getElementById('<%=ckbFinalDebitNote.ClientID %>').checked == false

 

JS回调服务器事件CallBack

 

JS操作ListBox

 

指定控件doPostBack

 

TextBox 回车事件
弹出页面--多按钮选择

页面无刷新
this.RegisterStartupScript("","<script>alert('hello')</script>");

posted on 2008-11-07 02:15  snowleopard  阅读(348)  评论(0)    收藏  举报

导航