Skip to content

Instantly share code, notes, and snippets.

@ludder

ludder/ios-hacks.js

Created Dec 6, 2012
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@ludder 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
You can’t perform that action at this time.