John Doe Smith
John Doe Smith

Reputation: 1643

Jquery SVG: How to get callback if browsers don't support svg?

I'm trying to find out how i can ask a browser if he supports JQuery SVG or not?

I have no idea with which browsers JQuery SVG is compatible with, because it isn't written/documentated anywhere.

But is there a way to ask the Browser if he supports svgs or JQuery SVG?

Like:

if (svg) drawSomething(); else loadAlternateImage();

I just want to draw 10 lines (but with complex algorithm).. so is jquery svg the best choice for this? I mean.. i use jquery a lot.

THX

Upvotes: 2

Views: 2533

Answers (2)

Simon Edström
Simon Edström

Reputation: 6619

I think you could have a lot of help by using Modernizer. It helps you detect whatever the client support functions. What I can read they have support for detecting SVG support.

http://www.modernizr.com/

I created this mini-demo: http://jsbin.com/ucabiz/edit#source

You use it like this:

if(Modernizr.svg)
//    Supported
}else{
// Unsupported
}

Upvotes: 11

tbleckert
tbleckert

Reputation: 3801

Try:

function supportsSvg() {
  return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0")
}

Upvotes: 5

Related Questions