所以我有这段代码可以在我的所有浏览器中运行,但在 IE 中有一个奇怪的行为。
$(document).ready(function () {
//$.ajaxSettings.cache = false;
var refresh = setInterval(function () {
$('div#top_right').load('refresh.php?randval=' + Math.random() * 99999);
}, 5000);
$.ajaxSetup({
// Disable caching of AJAX responses
cache: false
});
});
这会重新加载我的用户面板 div 并检查是否有任何新消息等(如您所见,我尝试在 IE 缓存中进行修改)。这适用于所有浏览器,甚至 IE,但在 IE 中,第一次重新加载后它会删除用户面板 div 中链接(例如消息链接)的所有 href 属性。我不知道为什么会这样。请帮忙?
这是 refresh.php 的代码:
<?php
session_start();
include_once 'functions.php';
$user = $_SESSION['user'];
$new_message = FALSE;
$new_friend = FALSE;
$new_reply = FALSE;
$query = "SELECT status FROM messages WHERE recip='$user'";
$result = queryMysql($query, "divs");
while($row=mysql_fetch_assoc($result)){
if($row['status']=='new') $new_message=TRUE;
}
$query2 = "SELECT status from friends WHERE user='$user'";
$result2 = queryMysql($query2, "nezworld");
while($row2=mysql_fetch_assoc($result2)){
if($row2['status']=='pending') $new_friend=TRUE;
}
$query3 = "SELECT status from replies WHERE recip='$user'";
$result3 = queryMysql($query3, "divs");
while($row3=mysql_fetch_assoc($result3)){
if($row3['status']=='new') $new_reply = TRUE;
}
?>
<div id="top_right"><ul id="login2">
<li class="user_nav"><a href="profile.php?view=<?php echo $user; ?>" class="white"><?php echo $user; ?></a></li>
<abbr title="Home"><a href="index.php" class='white'><li class='icons home'>N</li></a></abbr>
<abbr title="Messages"><a href="message.php?view=<?php echo $user; ?>" class='white'><?php if($new_message){?><li class='icons2 messages2'><?php }else{?><li class='icons2 messages'><?php }?>M</li></a></abbr>
<abbr title="Replies"><a href="replies.php?view=<?php echo $user; ?>" class='white'><?php if($new_reply){?><li class='icons2 replies4'><?php }else{?><li class='icons2 replies2'><?php }?>R</li></a></abbr>
<abbr title="Friend Requests"><a href="friends.php?view=<?php echo $user; ?>" class='white'><?php if($new_friend){?><li class='icons2 friends2'><?php }else{?><li class='icons2 friends'><?php }?>F</li></a></abbr>
<li><a class="submit" class='white' href="logout.php">LOGOUT</a>
</form>
</li>
</ul></div>