滚动< object>的内容标签使用jQuery [英] Scroll the content of <object> tag using jQuery

查看:96
本文介绍了滚动< object>的内容标签使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个网页,我正在使用对象标记将外部网页加载到div中。但是,外部页面的内容溢出而我无法看到整个内容。
所以我试图实现自动滚动功能,其中的对象的内容将逐步向下滚动,当它到达结束它应该向上滚动,请在下面找到我使用的代码。但我无法获得自动滚动功能: - (

I am using a web page where i am loading a external webpage into a div using object tag.However the content of the external page is overflowing and i am unable to see the whole content. So i have tried to implement the auto scroll feature where the content of the object will scroll down in steps and when it reaches end it should scroll up,please find below the code i have used.But i am unable to get the auto scroll functionality :-(

<script type="text/javascript"> 
    $(document).ready(function () {
        var interval = setInterval(function () {
            if ($("#objs").scrollTop() != $('#objs').scrollHeight) {
                $("#objs").scrollTop($("#objs").scrollTop() + 10);
            }
            else {
                clearInterval(interval);
            }
        }, 1000);
    }); 
</script>
<body>
     <div id="siteloader">    <%--div to load site--%>
         <object id="objs" data="http://www.w3schools.com//" ></object>
     </div>
</body>

我在执行此。提前感谢。

Please help me in implementing this.Thanks in advance.

推荐答案

$('#objs')是一个JQuery选择器,而 .scrollHeight 是一个本地JavaScript API。您必须添加JQuery .get()以将JQuery对象作为DOM集合开启,或者在JQuery选择器之后立即设置数组索引以使本机JavaScript API在JQuery选择器中工作:

$('#objs') is a JQuery selector, while .scrollHeight is a native JavaScript API. You have to add JQuery .get() to swtch back the JQuery object as DOM collection or set the array index right after the JQuery selector to make native JavaScript API works in JQuery selector:

// Example #1
$('#objs').get(0).scrollHeight

// Example #2
$('#objs')[0].scrollHeight

这篇关于滚动&lt; object&gt;的内容标签使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆