Skip to content

Instantly share code, notes, and snippets.

@ludder
Created December 6, 2012 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludder/4226305 to your computer and use it in GitHub Desktop.
Save ludder/4226305 to your computer and use it in GitHub Desktop.
iOS hacks
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT / GPLv2 License.
Source: https://github.com/scottjehl/iOS-Orientationchange-Fix
Explanation: http://adactio.com/journal/4470/
*/
// No code, check source above
/**
* A nasty bug in iOS prevents clicking on labels
* See also: http://v4.thewatchmakerproject.com/blog/how-to-fix-the-broken-ipad-form-label-click-issue/
*/
function addSafariLabelClick() {
if (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/iPad/i)) {
// Just an empty function should be enough to deal with this issue in iOS 5+
var labels = document.querySelectorAll('label');
for (var i=0; i<labels.length; i++) {
labels[i].addEventListener( 'click', function(){}, false);
}
}
}
@ludder
Copy link
Author

ludder commented Nov 4, 2016

Applying cursor:pointer to the label should have the same effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment