Home  >  Article  >  Web Front-end  >  JavaScript determines whether the browser supports SVG

JavaScript determines whether the browser supports SVG

高洛峰
高洛峰Original
2016-11-28 09:46:271212browse

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.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn