用jquery + iframe實現iframe子頁面加載完前的緩沖效果

來源:互聯網
上載者:User

作者:xyz

 

iframe:

 

<iframe name="rightFrame" id="rightFrame" style="margin:0px; WIDTH: 100%;  HEIGHT: 480px; VISIBILITY: inherit; background-color:transparent;  Z-INDEX: 3"
        scrolling="auto" allowTransparency="true" frameborder="0" src="order/myorders/init.do">
</iframe>

 

父頁面的調用:

 

<a onclick="clickDetails('<%=subM.getHref() %>');return false;" href="javascript:;" target="rightFrame"><%=subM.getText() %></a>

 

<script type="text/javascript">
    function clickDetails(strUrl){
        var loadHtml="<span style='padding-top:15px; text-align:right; color:#9b9b9b;font-size:12px;'>"+
            "<img alt='load' src='<%=request.getContextPath()%>/images/loading.gif' align='absMiddle'  bold='0'  /> 正在載入...</span>";
        $.ajax({
               type: "get",
               url: strUrl,
               data: "",
               dataType:"html",
               beforeSend:function(){
                frames['rightFrame'].document.body.innerHTML=loadHtml;
                //frames["rightFrame"].document.close();
                //frames["rightFrame"].document.write(loadHtml);  
               
               },
               success: function(msg){
                    //$("#rightFrame").Document.body.html(msg);
                    frames["rightFrame"].document.close();
                   frames["rightFrame"].document.write(msg);
                }
            });
    }
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.