W3C home > Mailing lists > Public > spec-prod@w3.org > January to March 2012

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 14 Mar 2012 07:51:31 -0700
Message-ID: <CAAWBYDCQmchk1eJE4DdPmpJ-cCi4CM7oaocsHPhf-utX-AGAWA@mail.gmail.com>
To: Philippe Le Hegaret <plh@w3.org>
Cc: Cameron McCormack <cam@mcc.id.au>, spec-prod <spec-prod@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 14 March 2012 14:52:25 GMT