首页javascriptiframejQuery HTML Element - 如何在iFrame中单击滚动

jQuery HTML Element - 如何在iFrame中单击滚动

我们想知道如何在iFrame中单击滚动。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<style type='text/css'>
#wrap {
  width: 400px;
  height: 200px;
  overflow: hidden;
  position: relative;
}

#frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 500px;
  height: 1000px;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $(document).ready(function() {
        $wrap = $('#wrap');
        // Simulate scrolling
        $wrap.prop('scrollTop', 500);
        $('#btnOk').bind('click', function(e) {
            $wrap.prop('scrollTop', 0);
        });
    });
});
</script>
</head>
<body>
  <button type="button" id="btnOk">Click Me!</button>
  <div id="wrap">
    <iframe id="frame" src="http://www.w3cschool.cn" scrolling="no"> </iframe>
  </div>
</body>
</html>