Answer the question
In order to leave comments, you need to log in
How to delete cookies on tab close?
I use this jquery code, in theory, without an expiration date, they should be deleted by themselves when the window is closed (not following the site links)
// если куки нет, то создаем
if( !$.cookie("first_visit") ){
// Creating and saving cookies
$.cookie("first_visit", "Visited!", { path: '/' });
// Redirect to... ( тут ссылка для перенаправления )
window.location.href = shop_url;
}
jQuery(document).ready(function($) {
var $ = jQuery;
function sreen_width_check(){
// Make variables
var main_page_url = 'http://piwo.com.ua/';
var shop_url = 'http://piwo.com.ua/shop/';
var curr_page_url = $(location).attr('href');
var screen_width = $(window).width();
// Requirements for redirection
if( curr_page_url === main_page_url ){
if ( screen_width <= 1280 ){
if( !$.cookie("first_visit") ){
// Creating and saving cookies
$.cookie("first_visit", "Visited!", { path: '/' });
// Redirect to...
window.location.href = shop_url;
}
}
}
};
sreen_width_check();
});
Answer the question
In order to leave comments, you need to log in
Tab close event , on which you need to hang your handler with deleting cookies :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question