我有一个奇怪的问题。我正在修复一个网页。在某些页面中,jquery 加载了以下行
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
在 Internet Explorer 中,如果我加载包含此行的页面,然后单击网页中的其他位置,则无论用户在何处注销都无关紧要。貌似这个函数最后才执行(使用PHP语言)
function logout()
{
global $db;
session_start();
/* Delete the user from table online */
mysql_query("DELETE FROM online WHERE user_id='$_SESSION[user_id]'");
/* Update the table last seen in table users */
$date_now = date("Y-m-d");
$time_now = date("H:i");
$date_last_seen = $date_now. ' '. $time_now;
mysql_query("UPDATE users SET date_last_seen = '$date_last_seen'
WHERE id='$_SESSION[user_id]'");
if(isset($_SESSION['user_id']) || isset($_COOKIE['user_id'])) {
mysql_query("update `users` set `ckey`= '', `ctime`= ''
where `id`='$_SESSION[user_id]' OR `id` = '$_COOKIE[user_id]'") or die(mysql_error());
}
/************ Delete the sessions****************/
unset($_SESSION['user_id']);
unset($_SESSION['user_name']);
unset($_SESSION['user_level']);
unset($_SESSION['HTTP_USER_AGENT']);
session_unset();
session_destroy();
/* Delete the cookies*******************/
setcookie("user_id", '', time()-60*60*24*COOKIE_TIME_OUT, "/");
setcookie("user_name", '', time()-60*60*24*COOKIE_TIME_OUT, "/");
setcookie("user_key", '', time()-60*60*24*COOKIE_TIME_OUT, "/");
header("Location: index.php");
}
会话被销毁,用户会话从数据库中删除,页面被重定向到 index.php。如果在登录页面中选择“记住我”以保存 cookie,则该页面可以正常工作。
在我加载 jquery 的 2 个不同页面中,我在顶部添加了这一行
<?php
session_set_cookie_params(1800);
session_start();
?>
它正确保存了会话 cookie,但最终没有任何反应,因为用户再次注销。
jquery 仅在 2 个页面中加载,仅在需要时加载。我试图把它放在通用标题上,但同样的问题发生了。当我删除 jquery 行时,页面工作正常,当然需要它的功能除外。所以这就像一个死胡同。
我提醒这仅在 IE 上发生(在 IE 8 和 IE 10 上测试)。在其他浏览器中它工作正常
这是应该在其中一个页面中执行的 jquery 代码
<script type="text/javascript" src="js/jquery.min.2012_09_29.js"></script>
<script type="text/javascript" src="js/jquery.opacityrollover.js"></script>
<script type="text/javascript" src="js/jquery.galleriffic.js"></script>
<!-- Optionally include jquery.history.js for history support -->
<script type="text/javascript" src="js/jquery.history.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('a#img_thumb').click(function() {
var del_name=$(this).attr('href');
del_name=del_name.replace('#','');
$('input[id="delete_image"]').attr('value',del_name);
});
});
</scipt>
和
<script type="text/javascript">
jQuery(document).ready(function($) {
// We only want these styles applied when javascript is enabled
$('div.navigation').css({'width' : '96px', 'float' : 'right'});
$('div.content').css('display', 'block');
// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.80;
$('#thumbs ul.thumbs li, div.navigation a.pageLink').opacityrollover({
mouseOutOpacity: onMouseOutOpacity,
mouseOverOpacity: 1.0,
fadeSpeed: 'fast',
exemptionSelector: '.selected'
});
// Initialize Advanced Galleriffic Gallery
var gallery = $('#thumbs').galleriffic({
delay: 1000,
numThumbs: 10,
preloadAhead: 10,
enableTopPager: false,
enableBottomPager: false,
imageContainerSel: '#slideshow',
controlsContainerSel: '#controls',
captionContainerSel: '#caption',
loadingContainerSel: '#loading',
renderSSControls: true,
renderNavControls: true,
playLinkText: 'Play Slideshow',
pauseLinkText: 'Pause Slideshow',
prevLinkText: '‹ Previous Photo',
nextLinkText: 'Next Photo ›',
nextPageLinkText: 'Next ›',
prevPageLinkText: '‹ Prev',
enableHistory: true,
autoStart: false,
syncTransitions: true,
defaultTransitionDuration: 200,
onSlideChange: function(prevIndex, nextIndex) {
// 'this' refers to the gallery, which is an extension of $('#thumbs')
this.find('ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
// Update the photo index display
this.$captionContainer.find('div.photo-index')
.html('Photo '+ (nextIndex+1) +' of '+ this.data.length);
},
onPageTransitionOut: function(callback) {
this.fadeTo('fast', 0.0, callback);
},
onPageTransitionIn: function() {
var prevPageLink = this.find('a.prev').css('visibility', 'hidden');
var nextPageLink = this.find('a.next').css('visibility', 'hidden');
// Show appropriate next / prev page links
if (this.displayedPage > 0)
prevPageLink.css('visibility', 'visible');
var lastPage = this.getNumPages() - 1;
if (this.displayedPage < lastPage)
nextPageLink.css('visibility', 'visible');
this.fadeTo('fast', 1.0);
}
});
/**************** Event handlers for custom next / prev page links **********************/
gallery.find('a.prev').click(function(e) {
gallery.previousPage();
e.preventDefault();
});
gallery.find('a.next').click(function(e) {
gallery.nextPage();
e.preventDefault();
});
/****************************************************************************************/
/**** Functions to support integration of galleriffic with the jquery.history plugin ****/
// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {
// alert("pageload: " + hash);
// hash doesn't contain the first # character.
if(hash) {
$.galleriffic.gotoImage(hash);
} else {
gallery.gotoIndex(0);
}
}
// Initialize history plugin.
// The callback is called at once by present location.hash.
$.historyInit(pageload, "advanced.html");
// set onlick event for buttons using the jQuery 1.3 live method
$("a[rel='history']").live('click', function(e) {
if (e.button != 0) return true;
var hash = this.href;
hash = hash.replace(/^.*#/, '');
// moves to a new page.
// pageload is called at once.
// hash don't contain "#", "?"
$.historyLoad(hash);
return false;
});
/****************************************************************************************/
});
</script>
这是gallerrific jquery插件
有任何想法吗?谢谢