Skip to content

Instantly share code, notes, and snippets.

@jackroscoe
jackroscoe / formTracker.js
Last active November 13, 2022 11:27
jQuery form drop out tracking for Google Universal Analytics
var ft_startDate = 0,
ft_startTime = 0,
ft_pageTitle = document.title,
ft_duration = false;
$(':input').focus(function() {
/* Make a record of when the user focused on the input */
ft_startDate = new Date();
ft_startTime = ft_startDate.getTime();
});
@jackroscoe
jackroscoe / supports3d.js
Last active December 19, 2015 19:58
Using Modernizr, Chrome 24 running on Windows XP claims it can't run 3d transforms. In fact, it does. This check gets around the false negative.
/* This was adpated from Daniel Ryan's gist @ https://gist.github.com/dryan/738720 */
function supports3d() {
// borrowed from modernizr
var div = document.createElement('div'),
ret = false,
properties = ['perspectiveProperty', 'WebkitPerspective'];
for (var i = properties.length - 1; i >= 0; i--){
ret = ret ? ret : div.style[properties[i]] != undefined;
};