[webkit-dev] getting contents of noscript element through DOM

mab2001 barborak at basikgroup.com
Mon Oct 12 09:30:59 PDT 2009


It seems that with webkit, the contents of the noscript tag cannot be
accessed through the DOM. FF and IE (haven't tested other browsers) allow
access through the textContent property but in Safari and Chrome this just
comes back blank. I've tried looking through the WebKit code to see why this
is happening but admit to being a little lost.

So my question is, is there a way to access the content of a noscript tag
through JavaScript? If not, would an enhancement request to allow this be
met favorably?

Here's the particular use case I am working on. A common technique when
embedding Flash in an HTML page is to first place an alternate content div
inside the HTML and then to replace that div with the Flash movie if it's
determined that the browser has JavaScript enabled and a high enough version
of the Flash player installed.

The problem with this approach is that heavy alternate content can hurt
performance even when it is not needed. For example, if it contains images,
those images will be put in the browser's load queue before the Flash movie.
So even though the image elements are removed from the DOM and replaced with
an embedded Flash movie, those images must still load prior to the browser
loading the Flash movie. (If anyone knows how to remove an image from the
load queue that might also be helpful.)

An approach to solving this problem that I have been trying has been to
place the alternate contents in a noscript tag. If the browser has
JavaScript disabled then the alternate content is shown. And if the browser
has JavaScript enabled but an older version of Flash installed, I basically
replace the noscript element with its contents rendered as HTML. When this
approach works, it's great because the alternate content HTML and images are
only parsed and added to the loader queue if needed.

Hopefully this use case is reasonable enough to sway anyone away from saying
the noscript tag should act as a impenetrable barrier between a browser with
JavaScript enabled and one without.

View this message in context: http://www.nabble.com/getting-contents-of-noscript-element-through-DOM-tp25858906p25858906.html
Sent from the Webkit mailing list archive at Nabble.com.

More information about the webkit-dev mailing list