jQuery Site Exit » Aug 12, 2010 1:30 PM » Coding
Here's a nifty little jQuery plug-in I made to watch for an external link and pop up one of those "You're leaving our site!1!" messages:

$(document).ready(function() { $("a[href^='http://']").click(function() {

urlOut = this.href;

$("#exitMsg").dialog({ modal: true, width: 400, draggable: false, resizable: false, buttons: { Cancel: function() { $(this).dialog('close'); }, Continue: function() { window.location.href = urlOut;}, } });

return false;

}); });

This one triggers the standard jQuery UI dialog box that has lots of customizable options. In this case there is a cancel button and a continue on to the external site button.

Tags: jQuery, HTML, code,