Home > Web Front-end > JS Tutorial > body text

JavaScript determines whether the browser supports SVG

高洛峰
Release: 2016-11-28 09:46:27
Original
1211 people have browsed it

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;  
}
Copy after login

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.


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template