Skip to content

Commit

Permalink
Fix: IE9 throws an error when using document.activeElement in a frame
Browse files Browse the repository at this point in the history
* See thread 21536 for more information
  • Loading branch information
Allan Jardine committed Jun 5, 2014
1 parent 9ba4130 commit d804658
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions js/ext/ext.paging.js
Expand Up @@ -142,17 +142,23 @@ $.extend( true, DataTable.ext.renderer, {
}
};

// Because this approach is destroying and recreating the paging
// elements, focus is lost on the select button which is bad for
// accessibility. So we want to restore focus once the draw has
// completed
var activeEl = $(document.activeElement).data('dt-idx');

attach( $(host).empty(), buttons );

if ( activeEl !== null ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
// IE9 throws an 'unknown error' if document.activeElement is used
// inside an iframe or frame. Try / catch the error. Not good for
// accessibility, but neither are frames.
try {
// Because this approach is destroying and recreating the paging
// elements, focus is lost on the select button which is bad for
// accessibility. So we want to restore focus once the draw has
// completed
var activeEl = $(document.activeElement).data('dt-idx');

attach( $(host).empty(), buttons );

if ( activeEl !== null ) {
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
}
}
catch (e) {}
}
}
} );
Expand Down

0 comments on commit d804658

Please sign in to comment.