jquery哪个事件比这个更好? [英] Jquery which event is better than this?

查看:110
本文介绍了jquery哪个事件比这个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html页面(父页面),里面有一个iframe。当您在iframe内导航时(重新加载iframe的页面或点击链接),父页面将保持原有位置。所以我使用scrollTop返回页面顶部。



所有工作正常,但jquery只有在iframe完全加载时才会执行此操作(image inluded ..) ... $ / $>

如何在iframe的页面完全加载之前,scrollTop(PARENT PAGE)?



 < script language =javascriptsrc =http://ajax.googleapis。 com / ajax / libs / jquery / 1.3.2 / jquery.min.jstype =text / javascript>< / script> 
< script type =text / javascript>
jQuery(document).ready(function(){
$('iframe')。load(function(){
$(window).scrollTop(0);
});
});< / script>
< iframe frameborder =0height =1000id =iframesrc =http://mysite.comwidth =800>< / iframe>

Thanx !!!

解决方案

我认为你可以这样做:

 < script type =text / javascript > 

jQuery(document).ready(function(){
$ b $(window).scrollTop(0);
});
< / script>


I have a page in html (parent page) that have inside an iframe. When you navigate inside iframe (reload iframe's page or click on link) the parent page remains in its previous position. So i used scrollTop to bring back at the top the page.

All works fine but jquery do it only when the iframe is completely loaded (image inluded..) so this is not well...

How can i scrollTop (PARENT PAGE) before the iframe's page is completely loaded?

Parent page body code:

<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
    $('iframe').load(function(){
         $(window).scrollTop(0);
    });
});</script>
<iframe frameborder="0" height="1000" id="iframe" src="http://mysite.com" width="800"></iframe>

Thanx!!!

解决方案

I think you could just do this :

<script type="text/javascript">

jQuery(document).ready(function() {

         $(window).scrollTop(0);
    });
</script>

这篇关于jquery哪个事件比这个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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