jquery加载冻结页面 [英] jquery load freezing the page

查看:84
本文介绍了jquery加载冻结页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$(document).ready(function(){
$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");

$("a[target!='_blank'][target!='_top']").click(function(){


$("#actualcontent").load($(this).attr("href"));
$("#nav").load('nav.php');

window.location.hash=$(this).attr("href");
        return false;
    });
});

此代码工作正常,但是当您点击链接时,页面会加载,但会冻结页面直到完全加载。是否有解决方法?

This code works fine, but when you click links, the pages load but they freeze the page until fully loaded. Any idea of a workaround?

此脚本嵌入在页面底部。它有时也会重新加载页面 - 这不是一个真正的问题,但是当它冻结时,它会变得非常令人沮丧。以及当您在输入中输入信息时。

This script is embedded at the bottom of the page. It also sometimes reloads the page - which isn't really a problem, but when it's freezing, it can become very frustrating. As well as when you're entering information into a input.

如果您有任何问题,我会很快回复。干杯;)

If you ask any questions, I will reply to them pretty quickly. Cheers ;)

此外,此脚本适用于初始页面上的所有链接,但如果我加载新页面(通过此脚本),其链接只是正常打开。

Also, this script works with all the links on the initial page, but if I load a new page (via this script), their links just open normally.

我该如何解决这个问题?好像我将这个脚本嵌入到每个页面中,它似乎使页面不断重新加载。 (虽然这可能是另一个错误。)

How can I work around this? As if I embed this script into every page, it seems to make the page reload continuously. (That could be another error though.)

推荐答案

我遇到类似的问题,浏览器冻结了jquery .ajax()函数。如果您正在本地开发和测试,由于某种原因,它会冻结Web浏览器,直到检索到数据。将我的代码上传到Web服务器后,它开始工作没有问题。我希望这会有所帮助,因为我花了好几个小时为自己弄明白。还要确保async属性设置为true(默认情况下为true)。

I had a similar problem with the browser freezing with jquery .ajax() function. If you are developing and testing locally, for some reason it freezes the web browser until the data is retrieved. After uploading my code to a web server it started to work with no problems. I hope this helps, because it took me hours to figure it out for myself. Also make sure async property is set to true (by default it is true).

这篇关于jquery加载冻结页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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