开发者

ASP.NET Detect SVG Capability Server Side

Is there a way to detect whether or not a browser has SVG capability server side? I know how to do this on the client, but 开发者_如何学CI'd like to detect it on the browser.


Server-side browser detection or capability detection is notoriously prone to error.

The only visibility you have at the server of what browser the user has is the user agent string.

Unfortunately, this is completely unreliable, as it can be spoofed by the client. It is also often blanked out for privacy reasons by various firewall and security products, and some proxies also modify it or remove it.

In short, there's no reliable way to detect the browser from the server.

I have two suggestions for you:

1) Use an AJAX method. Detect the feature in Javascript as normal (using Modernizr, or your favourite other technique), and then send the result of that detection back to the server. It can still be intercepted and spoofed if the user really wanted to, but less likely, and will definitely get around the issues I described with firewalls and proxies.

2) Why care about SVG support when the only browser in common use which doesn't support it is IE8 (and lower)? IE supports VML instead, and there are any number of Javascript tools available for converting SVG to VML so that apps using SVG can work in all browsers. My favourite is Raphael, but Raphael is a library for drawing the graphics; since you already have the SVG, you may find a simple conversion library is more useful. Something like this, perhaps: http://code.google.com/p/svg2vml/ or this: http://code.google.com/p/svgweb/

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜