make the piwik code work with IE at least down to 8
authorRobert Kaiser <kairo@kairo.at>
Thu, 15 Dec 2016 23:28:16 +0000 (00:28 +0100)
committerRobert Kaiser <kairo@kairo.at>
Thu, 15 Dec 2016 23:28:16 +0000 (00:28 +0100)
app/piwik.js

index 4896dc4cfb7fdae7f47f1fbf4e4cc45fd69e5670..86a1c35515feb7fd9635b83846f24ddceeca1961 100644 (file)
@@ -4,10 +4,10 @@
   _paq.push(['enableLinkTracking']);
   (function() {
     var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
-    // dataset does not work with IE10 or lower :(
-    var u=s.parentNode.dataset.piwikurl;
+    // dataset does not work with IE10 or lower, so work around it with .getAttribute() :(
+    var u=(s.parentNode.dataset?s.parentNode.dataset.piwikurl:s.parentNode.getAttribute('data-piwikurl'));
     _paq.push(['setTrackerUrl', u+'piwik.php']);
-    _paq.push(['setSiteId', s.parentNode.dataset.piwiksite]);
+    _paq.push(['setSiteId', (s.parentNode.dataset?s.parentNode.dataset.piwiksite:s.parentNode.getAttribute('data-piwiksite'))]);
     g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
   })();
 // End Piwik code