Jquery自动刷新耗尽了很多浏览器内存.有办法阻止这个.我每隔3秒刷一次2 div,但我将其移动到9和15秒,它帮助我的网站上的窗口保持打开的时间越长,浏览器崩溃之前所需的内存就越多.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script>
var auto_refresh = setInterval(
function ()
{
$('#details2').load('links2.php').fadeIn("slow");
}, 15000); // refresh every 10000 milliseconds</script>
Run Code Online (Sandbox Code Playgroud) 这个脚本在我的成员计算机上占用了大量资源.我有其他间隔脚本,不会占用任何资源.我已经尝试延长时间,但这会减慢刷新速度.有什么建议?
<script type="text/javascript">
$('document').ready(function(){
updatestatus();
scrollalert();
});
function updatestatus(){
//Show number of loaded items
var totalItems=$('#scontent p').length;
$('#status').text('Done');
}
function scrollalert(){
var scrolltop=$('#scrollbox').attr('scrollTop');
var scrollheight=$('#scrollbox').attr('scrollHeight');
var windowheight=$('#scrollbox').attr('clientHeight');
var scrolloffset=10;
if(scrolltop>=(scrollheight-(windowheight+scrolloffset)))
{
//fetch new items
$('#status').text('Loading more members...');
$.get('allonline.php', '', function(newitems){
$('#scontent').load('allonline.php');
updatestatus();
});
}
setTimeout('scrollalert();', 60000);
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有2个页面,一个PHP和一个Javascript.我想在一个页面上传递这个PHP脚本中的变量:
$strFind="SELECT * FROM cometchat_chatrooms_users WHERE userid=$curmemid";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$room=$row['chatroomid'];
Run Code Online (Sandbox Code Playgroud)
在另一个页面上的这个Javascript:
var timestamp = 0;
var currentroom = $room;
var heartbeatTimer;
var minHeartbeat = 3000;
var maxHeartbeat = 12000;
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?