簡體   English   中英

如何檢查iframe html文件滾動是否到達底部或不使用jQuery

[英]How to check iframe html file scroll is reached to bottom or not using jquery

我在asp.net MVC3中有以下查看頁面,

@using (Html.BeginForm())
{
<p>
test test
test test
test test
test test
test test
</p>
<article border="0" >
<iframe src ="@Url.Content("~/Content/test.html")" width="100%" height="300px" id="iframeContent"></iframe>
</article>
<p>
test test
test test
test test
test test
test test
</p>
<table>
<tr>
<td>
sample data
</td>
</tr>
</table>
}

iframe src html文件很小,因此具有滾動功能。 我想檢查html文件滾動是否到達底部。 如果到達底部,我需要進行一些驗證。

我可以使用下面的jquery來完成整個頁面的工作,但是我無法弄清楚如何僅對iframe滾動內容進行處理。 有什么建議嗎?

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("Bottom Reached!");
   }
});

嘗試這個:

$('iframe').bind('load',function(){
    var $win=$('iframe').get(0).contentWindow;
    $win.scroll(function() {
       if($win.scrollTop() + $(window).height() == $(document).height()) {
           alert("Bottom Reached!");
       }
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM