W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] attribute "media" on "script" element

From: Filippo Levizzani <filippo.levizzani@gmail.com>
Date: Fri, 14 Nov 2008 18:53:47 +0100
Message-ID: <12e08aa20811140953gd266c4ak8479693a64cf52e9@mail.gmail.com>
On Fri, Nov 14, 2008 at 5:43 PM, L. David Baron <dbaron at dbaron.org> wrote:

> On Friday 2008-11-14 11:37 +0100, Filippo Levizzani wrote:
> > Would it be possible to have "media" attribute in the SCRIPT element?
> >
> > Addmitted vaues would be the same of STYLE element (all, screen, print,
> > handheld ...)
>
> I'm not quite sure how this would work, since there are two things
> that seem incompatible:
>
>  * scripts are executed during parsing / content model construction


in theory the script would just be skipped (as there is no script tag at
all).
I don't know if the media type is known only at the end of model
construction... if so, then it would be a problem :-/


>
>
>  * whether a media attribute is true can change over time


but the same applies to style element , I guess

>
>
> This seems to imply that we'd have to go un-execute a script, or
> that we'd have to execute later something that was skipped earlier,
> even when that no longer makes sense.
>
>
> What was the actual use case you were trying to solve with this
> attribute?


For instance, I'd like to call SWFObject function (to replace html content
with flash) only if media=screen.
Other times there are js funcions that have no sense if a given style sheet
has not been applied to the page.

Filippo


>
>
> -David
>
> --
> L. David Baron                                 http://dbaron.org/
> Mozilla Corporation                       http://www.mozilla.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20081114/a84d14b8/attachment.htm>
Received on Friday, 14 November 2008 09:53:47 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC