笔记

嵌入子页面的方法
<input id="btnSendMobileInfo" runat="server" value="发送短信" type="button" onclick="$('#tlOrderSms').toggle();" />
<table id="tlOrderSms" width="100%" border="0" align="center" cellpadding="0" cellspacing="1"
                    bgcolor="#FFFFFF" class="tableBorder" style="display: none">
                    <tr>
                        <td colspan="3" align="center">
                            <iframe src="SendMobileMessage.aspx?orderscode=<%=OrdersCode %>"
                                name="MessageFrom" id="MessageFrom" marginwidth="0" marginheight="0" onload="this.height=80"
                                width="100%" frameborder="0" scrolling="auto"></iframe>
                            <script type="text/javascript">
                                function reinitIframe() {
                                    var iframe = document.getElementById("MessageFrom");
                                    try {
                                        var bHeight = iframe.contentWindow.document.body.scrollHeight;

                                        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

                                        var height = Math.max(bHeight, dHeight);

                                        iframe.height = height;

                                    } catch (ex) { }
                                }
                                window.setInterval("reinitIframe()", 2000);
                            </script>
                        </td>
                    </tr>
                </table>

javascript中的onkeyup和onkeydown区别
都是监视键盘行为,只是触发的时机不一样。
键盘按下的时候会触发onkeydown,松开键盘时会出发onkeyup。
使用场景不一样。

$(document).ready(function() {});,直接在<script></script>中写事件,方法
$(document).ready 里的代码是在页面内容都加载完才执行的,你直接写到script标签里,当页面加载完这个script标签就会执行里边的代码了,如果你标签里执行的代码调用了当前还没加

载过来的代码或者dom,那么就会报错,
当然如果你把script标签当到页面最后面那么就没问题了和ready差不多的效果


匹配父窗口与子窗口的大小
 function SendMobileInfo() {
          $('#tlOrderSms').toggle();
          if (!$("#tbSmsTemplate").is(":hidden")) {
              $('#tbSmsTemplate').toggle();
          }
          window.parent.$('#MessageFrom').height($('#tlOrderSms').height() + 60);
      }

非常有用的博客::http://blog.csdn.net/tjvictor/article/details/4360030

 

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder">
                    <tr>
                        <td height="10" width="10px">
                            <input id="SendId" runat="server" value="发送短信" type="button" onclick="SendMobileInfo()" />
                        <input id="SendId2" runat="server" value="发送短信" type="button" onclick="SendTemplateInfo()" />
                        </td>
                    </tr>
                </table>
                <table id="tlOrderSms" width="100%" border="0" align="center" cellpadding="0" cellspacing="1"
                    bgcolor="#FFFFFF" class="tableBorder" style="display: none">
                    <tr>
                        <th height="25">发送短信提示
                        </th>
                    </tr>
                    <tr>
                        <td align="center">短信内容:<asp:TextBox ID="txtSendContent" runat="server" Height="108px" Width="500px"
                            TextMode="MultiLine" onkeyup="GetHowManyChar()" onkeydown="GetHowManyChar()"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" height="25">已输入<font color="#ff0000"><label id="SmsLen"></label></font>字符,最大只能输入<font color="#ff0000">64</font>字符!
                        </td>
                    </tr>
                    <tr>
                        <td align="center" height="25">
                            <asp:Button ID="btnSubmitMobileInfo" runat="server" Text="发 送" OnClick="btnSubmitMobileInfo_Click" OnClientClick="javascript:disabledBtnSubmit()" />&nbsp;&nbsp;
                        <asp:Button ID="btnCancel" runat="server" Text="取 消" />
                        </td>
                    </tr>
                </table>

 

 //获取已输入字符数
      function GetHowManyChar() {
          document.getElementById("SmsLen").innerHTML = document.getElementById("txtSendContent").value.length;
      }

posted on 2015-12-02 20:17  +=  阅读(245)  评论(0编辑  收藏  举报

导航