Home > Web Front-end > JS Tutorial > JavaScript code to determine whether the browser supports SVG_javascript skills

JavaScript code to determine whether the browser supports SVG_javascript skills

WBOY
Release: 2016-05-16 17:39:48
Original
1054 people have browsed it

Scalable Vector Graphics (SVG) is a graphics format based on Extensible Markup Language (XML) for describing two-dimensional vector graphics. SVG is developed by W3C and is an open standard. In addition, SVG is also the abbreviation of Static Var Generator

The code to determine whether the browser supports SVG (part of it is cut from the Highcharts source code):
Js code:

Copy code The code is as follows:

function hasSVG(){
SVG_NS = 'http://www.w3.org /2000/svg',
return !!doc.createElementNS &&
!!doc.createElementNS(SVG_NS, 'svg').createSVGRect;
}

Not supported by IE8 SVG, so when setting the legend horizontal position for the Highcharts chart and setting the same x value, the display effects of Chrome and IE are 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