Reputation: 981
I'm trying to devise a way to display an SVG image when rendering is supported and a png in the fallback case. I would like to do this on the server side for performance reasons because both are image formats are generated dynamically.
Is there a way to use the Page.Request.Browser to determine if SVG is supported?
Upvotes: 0
Views: 173
Reputation: 981
I ended up hardcoding the browser version after finding this table. The versioning support is pretty straightforward so I just made a case statement. Based on the table everything else should support SVG (at least partially). I don't need to support "Android Browser" so I left it out.
System.Web.HttpBrowserCapabilities browser;
switch (browser.Browser)
{
case "Firefox":
case "Mozilla":
{
return browser.MajorVersion >= 3;
}
case "IE":
case "IEMobile":
{
return browser.MajorVersion >= 9;
}
default:
{
return true;
}
}
Upvotes: 1
Reputation: 2136
You could code separate partial pages one with the PNG image and one with SVG. And in the client you could detect the support and make a get request to one of the partial pages and place it in the DOM.
Upvotes: 0
Reputation: 971
Maybe not exactly what you were looking for but I remember that Modernizr.js has support for that
bool Modernizr.svg
Your could point to an action with this bool in the query string.
Upvotes: 0