|
 |
|
สอบถามเรื่องการ Jquery UI Tab ตั้งให้ Cookie หมด อายุ หลังจาก 30 นาที ทีค่ะ |
|
 |
|
|
 |
 |
|
สอบถามเรื่องการ Jquery UI Tab ตั้งให้ Cookie หมด อายุ หลังจาก 30 นาที ทีค่ะ
Code (JavaScript)
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#tab').tabs({
ajaxOptions: {
error: function(xhr,index,status,anchor) {
$(anchor.hash).text('load error');
}
},
//event: 'mouseover',
collapsible: true,
cookie: {expires: 1}
}).find('.ui-tabs-nav').sortable({axis: 'x'});
});
</script>
ส่วนของ Jquery
jQuery.cookie = function (key, value, options) {
// key and value given, set cookie...
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
options = jQuery.extend({}, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? String(value) : encodeURIComponent(String(value)),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
Tag : PHP, JavaScript, jQuery

|
|
 |
 |
 |
 |
Date :
2014-01-18 15:56:51 |
By :
MiRoKoJuMG |
View :
1090 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
30 นาที = 30 * 60 * 1000
Code (PHP)
<script type="text/javascript">
$(document).ready(function(){
var expDate = new Date();
expDate.setTime(expDate.getTime() + (30 * 60 * 1000));
$('#tab').tabs({
ajaxOptions: {
error: function(xhr,index,status,anchor) {
$(anchor.hash).text('load error');
}
},
//event: 'mouseover',
collapsible: true,
cookie: {expires: expDate}
}).find('.ui-tabs-nav').sortable({axis: 'x'});
});
</script>
|
 |
 |
 |
 |
Date :
2014-01-19 12:08:44 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากเลยนะค่ะ (^//^)
|
 |
 |
 |
 |
Date :
2014-01-22 19:38:04 |
By :
MiRoKoJuMG |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|