3

There is a html page that I have no control over, ditto goes for any javascript.

I can however style it, and one of the thing's I've done is injected a slab of text via content in a CSS pseudo-element.

However this slab is multiple lines and with CSS strings being only one line leads to a cumbersome property full of \0as.

I was wondering whether I could use the url(blah/blah) syntax with content in place of a string; and the docs say yes!

enter image description here

However, when I try it (the slab now unencoded and hosted in it's own file), the content doesn't show.
Looking in the networking tab of the devtools shows it is requested, but it looks like the browser is ignoring it.

At first I thought it was a headers issue (I was working just out of the filesystem), so I built a tiny server to apply text/plain (I also tried text/html) on localhost.

It appears the browsers are only accepting images for content, with the following header seen to be sent with the request in chrome's devtools; Accept:image/webp,image/*,*/*;q=0.8.

This issue occurs in firefox too, so why does the mdn specifically use a .html example in the syntax?
Is there any way to get something like what I'm attempting up and running, or am I left to deal with the long CSS statement?

Hashbrown
  • 12,091
  • 8
  • 72
  • 95
  • While this won't solve your problem, I shall hope nasty things like this will never go mainstream. –  Dec 31 '15 at 01:58
  • I completely agree. Oh you should see the page, it looks fantastic [with all my CSS layered on it], but the HTML [that isn't mine] is just god awful. But I need things like this for situations like these, it's the nasty situations I hope never go mainstream. – Hashbrown Dec 31 '15 at 02:11

1 Answers1

1

The docs say "an external resource (such as an image)" so they don't explicitly rule out such use of plain text, but they don't explicitly allow it either. It seems likely that "such as an image" is intended to allow further media types such as video or interactive SVG but deliberately vague so as to not second-guess future technologies.

As such, it would seem that it's "permitted" as in you haven't done anything invalid, but not supported as in there is no reason why you should expect it to actually do anything useful.

This issue occurs in firefox too, so why does the mdn specifically use a .html example in the syntax?

I'd guess that it was simply a RFC 6761- and RFC 2606-compliant example URI often used in the docs as an example URI. (Of course, to nitpick, there's no reason why a URI ending in .html should be assumed to always return HTML either, though its a bit perverse to do otherwise).

Jon Hanna
  • 110,372
  • 10
  • 146
  • 251
  • My sentiments precisely. Oh well. I'm just incorporating the 'convert/escape/encode the nice paragraphs from this file into a single line for this file' into the build process – Hashbrown Dec 31 '15 at 02:13