Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Requesting some test feedback for Android 4.4 CSS calc() support Reply To: Requesting some test feedback for Android 4.4 CSS calc() support

#248947
Shikkediel
Participant

No need to go and check on the aforementioned site anymore by the way, I’ve put a fix in place. Some PHP browser sniffing, which I would normally not prefer at all. On the basis of that, the extra bit of script is loaded that would otherwise break things.

:-/

<?php
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$blend = [];
preg_match('/Android.*AppleWebKit\/([\d.]+)/', $_SERVER['HTTP_USER_AGENT'], $blend);

if (isset($blend[1]) && intval($blend[1]) < 537) {
echo '<script>window.inept = true</script>'."\n";
}
else {
echo '<script src="myplugin,js"></script>'."\n";
}
}
else {
echo '<script src="myplugin.js"></script>'."\n";
}
?>

Then I look for 'inept' in window. If it’s there, only delete it. Otherwise use $.getScript to load the few lines that initiate the plugin. This will happen inside the main script that follows the PHP above in the document.

A lot easier to maintain than having two completely separate scripts…

The number 537 is a version check for when stock browser became Chrome, with the better JS engine.