h1 Inline SVG testing
p After some problems with Modernizr tests I found about SVGRect in this <a href="http://stackoverflow.com/a/28239372/2728847"target="_blank">Stackoverflow answer</a> and I am testing this against Modernizr's test to see which is more reliable.
p I'm using this pen for testing across browsers.
p.modernizr
p.svgrect
svg(viewBox="0 0 200 200" version="1.1" style="width: 100px; height: 100px;")
circle(cx="100" cy="100" r="80" fill="green" stroke ="darkgreen" stroke-width ="10")
p Results:
table(border="1")
tr
td: b Browser
td: b Modernizr
td: b SVGRect
tr
td Chrome 40 for Mac
td.success Test is successful
td.success Test is successful
tr
td Firefox 36.0.1 for Mac
td.success Test is successful
td.success Test is successful
tr
td Firefox 35.0.1 for Mac
td.success Test is successful
td.success Test is successful
tr
td Safari Mac 8.0.2
td.success Test is successful
td.success Test is successful
tr
td Internet Explorer 11
td.success Test is successful
td.success Test is successful
tr
td Internet Explorer 10
td.success Test is successful
td.success Test is successful
tr
td Internet Explorer 9
td.success Test is successful
td.success Test is successful
tr
td Internet Explorer 8
td.success Test is successful
td.success Test is successful
tr
td Safari iOS 5
td.success Test is successful
td.success Test is successful
tr
td Safari iOS 6
td.success Test is successful
td.success Test is successful
tr
td Safari iOS 7
td.success Test is successful
td.success Test is successful
tr
td Safari iOS 8
td.success Test is successful
td.success Test is successful
tr
td Android 2.2 browser<br> Android Simulator on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Android 2.3 browser<br> Android Simulator on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Android 3.2 browser<br> Samsung Galaxy Tab 10.1 (GT-P7500)
td.success Test is successful
td.success Test is successful
tr
td Android 4.0 browser<br> Android Simulator on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Android 4.1 browser<br> Galaxy Tab 2 on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Android 4.2 browser<br> <a href="http://app.crossbrowsertesting.com/public/iec9d6738c0f1080/livetests/2764871/snapshots/zdabbc2161a2c802588b" target="_blank">Samsung Galaxy S4 on CrossBrowserTesting</a>
td.fail Test falied
td.success Test is successful
tr
td Android 4.2.2 browser<br> Samsung Galaxy Y TV custom ROM (GT-S5367)
td.success Test is successful
td.success Test is successful
tr
td Opera Mini 7.6 on Android 4.2.2<br> Samsung Galaxy Y TV custom ROM (GT-S5367)
td.success Test is successful
td.fail Test failed
tr
td Chrome 40 on Android 4.4.4<br> Moto G 2
td.success Test is successful
td.success Test is successful
tr
td Android 4.4.4 browser<br> Galaxy S5 on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Android 5.0 browser<br> Android x86 on VirtualBox
td.success Test is successful
td.success Test is successful
tr
td Blackberry Browser<br> Bold 9900 on CrossBrowserTesting
td.success Test is successful
td.success Test is successful
tr
td Windows Phone 8
td.success Test is successful
td.success Test is successful
p: b The test is successful when it detects correctly if the browser supports or not SVG.
View Compiled
body {
padding: 2em;
}
.success {
color: green;
}
.fail {
color: red;
}
table td {
padding: 8px;
}
View Compiled
var modernizrTest = document.querySelector(".modernizr"),
svgrectTest = document.querySelector(".svgrect");
// Modernizr's test
if (Modernizr.inlinesvg) {
modernizrTest.innerHTML = "<b>Modernizr</b> says that your browser supports SVG. If you see a green circle the test works.";
modernizrTest.style.color = "green";
} else {
modernizrTest.innerHTML = "<b>Modernizr</b> says that your browser doesn't supports SVG. If you can't see a green circle the test works.";
modernizrTest.style.color = "red";
};
// SVGRect's test
if (typeof SVGRect != "undefined") {
svgrectTest.innerHTML = "<b>SVGRect</b> says that your browser supports SVG. If you see a green circle the test works.";
svgrectTest.style.color = "green";
} else {
svgrectTest.innerHTML = "<b>SVGRect</b> says that your browser doesn't supports SVG. If you can't see a green circle the test works.";
svgrectTest.style.color = "red";
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.