Home > Article > Web Front-end > JavaScript determines whether the browser supports SVG
Code to determine whether the browser supports SVG (partly cut from the Highcharts source code):
Js code:
function hasSVG(){ SVG_NS = 'http://www.w3.org/2000/svg', return !!doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect; }
IE8 does not support SVG, so when setting the legend horizontal position for the Highcharts chart, set the same x value, Chrome and IE The display effect is inconsistent. Therefore, it is necessary to determine whether the browser supports SVG and set different x values according to different results.