1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
$(document).ready(function () {
var confirmMsg = 'Please provide your feedback.';
function isInternal(anchor) {
var patt = new RegExp("^http://mon.site.com/+.*", "i");
return patt.test(anchor.href);
}
function handler(e) {
setTimeout(function () {
$(window).unbind("beforeunload");
$.cookie("survey", true, {
path : "/",
expires : 365
});
window.open("<survey-url>", "_blank");
var event = (e || window.event)
if (event) {
event.returnValue = confirmMsg
}
}, 50);
// For Safari
return confirmMsg;
}
$("a").click(function (event) {
// external link
if (!isInternal(this)) {
if ($.cookie("survey") == null) {
$(window).on('beforeunload', handler);
}
}
});
}); |
Partager