conditional comment or fallback for SVG

Hi,

We have a lot of content that is currently flash based because we needed the art to scale with the browser window. We have now made most of those items into SVG and can accomplish the same thing using a little javascript and the svg file. The problem we are running into is that IE doesn't work right with the SVG's and Android Browser also will not display SVG's (unless the Android is Version 2.4 or greater, which the majority of our users are not on 2.2 and 2.33 seem to be the most used).

Initially I used conditional comments to display the old flash object on IE and hide it from everything else, but that leaves android not displaying anything at all on the page. When I use down-level revealed conditional comments then FF/Chrome/etc... load both the flash and the svg, fortunately the SVG covers the flash because of the way we have it coded, but I don't want both objects to have to load... it's a waste of bandwidth and makes the page take twice as long to display...

The new html5 audio and video tags have that nice fallback feature but their doesn't seem to be anything like that for SVG...

Does anyone know how I can get this working so SVG displays for those that can see it and if they can't then it displays Flash?

Thanks!
LVL 17
jrm213jrm213Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lisfolksCommented:
The following article is titled for iPad/iPhone support; however, I think the discussion might help in your situation.

desideratum | Fallback from Flash to HTML5 video for iPad/iPhone Support
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jrm213jrm213Author Commented:
Well I finally got this sorted out. It isn't the best scenario but it seems to be working.

so we used the Google Swiffy to convert the flash into SVG and display it on the page. Then we set the flash object/embed code as a javascript varialbe and in a try catch block we start the swiffy stage and append the javascript variable to the svg tag. In the catch error block we just add the flash variable to the page using document.write.

So for anything that can correctly display SVG, the SVG is displayed, if the browser doesn't know what SVG is, it displays the flash. If it has a problem with the swiffy code it displays the flash. I force IE to display in compatibility of IE8 through a meta in the header, because IE9 thinks it can display the swiffy SVG output and it can't (it just fails and displays nothing).

Tested on IE8, IE9, Firefox (most recent version), IPad, Android Phone, Android Tablet, Safari, Opera, and Chrome

IE8,IE9, Android < 2.4, and Opera display the flash
Everything else gets the svg.

I am hoping that the way this is coded in the future when everything can handle svg correctly that everything will display and use the svg code only.

so the structure looks something like this


<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >
<meta charset="utf-8">
<title>page title</title>
<script type="text/javascript" src="jquery-1-4-2-min.js"></script>
<script src="http://www.gstatic.com/swiffy/v3.6/runtime.js"></script>
<script>
swiffyobject = [output from swiffy];
</script>
</head>
<body style="overflow:hidden;margin:0;">

<script>var stage = new swiffy.Stage(document.body, swiffyobject);</script>
<script>
var flashobj;
flashobj = [object/embed for flash];
try
{
	stage.start();
	jQuery('svg').append(flashobj);
}
catch(err)
{
	document.write(flashobj);
}
</script>
</body>
</html>

Open in new window


0
jrm213jrm213Author Commented:
The article helped some, had to use trial and error to get this to work correctly on all platforms we needed it to work on.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.