Re: Fall mechanisms (Re: [Pubrules] Changes to enable use of HTML5)

On Wed, Mar 14, 2012 at 7:02 AM, Philippe Le Hegaret <plh@w3.org> wrote:
> On Wed, 2012-03-14 at 11:37 +1100, Cameron McCormack wrote:
>> Do you have a concrete suggestion on how to implement this fallback?  I
>> cannot think right now of a way to do this without script, for example:
>>
>>    <!DOCTYPE html>
>>    <style>
>>      body.no-inline-svg svg,
>>      .svg-fallback { display: none }
>>      body.no-inline-svg .svg-fallback { display: initial }
>>    </style>
>>    <body>
>>    <svg></svg>
>>    <script>
>>      var e = document.getElementsByTagName("svg")[0];
>>      if (e.namespaceURI != "http://www.w3.org/2000/svg") {
>>        document.body.className = "no-inline-svg";
>>      }
>>      e.parentNode.removeChild(svg);
>>    </script>
>>    <p>Consider the following diagram:</p>
>>    <svg>
>>      <path d="..."/>
>>    </svg>
>>    <img class=svg-fallback src=diagram.png>
>
> That would work for me at least. It guarantees that you'll see something
> independently of whether scripting is enabled or not.

Here's something even simpler:

<!doctype html>
<figure>
  <svg>
    <defs>
      <foreignObject>
        <img src="fallback.png" />
      </foreignObject>
    </defs>
    ...real image here
  </svg>
  <figcaption>I'm an image!</figcaption>
</figure>

In UAs that support SVG, the <img> will never be rendered.  In UAs
that don't, you'll just get an <img> wrapped up in a bunch of unknown
inline elements.

~TJ

Received on Wednesday, 14 March 2012 14:52:24 UTC