Javascript 如何使用jquery检查iframe html文件滚动是否到达底部
我在asp.net MVC3中有下面的查看页面Javascript 如何使用jquery检查iframe html文件滚动是否到达底部,javascript,jquery,html,css,iframe,Javascript,Jquery,Html,Css,Iframe,我在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
@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').bind('load',function(){
var $win=$('iframe').get(0).contentWindow;
$win.scroll(function() {
if($win.scrollTop() + $(window).height() == $(document).height()) {
alert("Bottom Reached!");
}
});
});
尝试将其添加到文档准备事件。可能调用函数时iframe不在dom中
$('iframe').bind('load',function(){
var $win=$('iframe').get(0).contentWindow;
$win.scroll(function() {
if($win.scrollTop() + $(window).height() == $(document).height()) {
alert("Bottom Reached!");
}
});
});