Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26386

Re: TXT file into Iframe causes warning

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: TXT file into Iframe causes warning
Date 2014-12-26 10:00 +0200
Organization A noiseless patient Spider
Message-ID <m7j4hf$9v2$1@dont-email.me> (permalink)
References <6NO2IGEp0$mUFwtJ@invalid.uk.co.demon.merlyn.invalid>

Show all headers | View raw


2014-12-25, 14:03, Dr J R Stockton wrote:

> BUT - Web Console gives the Warning  "! The character encoding of a
> framed document was not declared. The document may appear different if
> viewed without the document framing it."  which is annoying.

This issue can be reproduced simply by using, in a local document, an 
<iframe> element that refers to a local plain text document, with just 
<iframe src=foo.txt></iframe>. So the issue has really nothing to do 
with JavaScript as such, and it seems there there is no JavaScript 
solution either (browsers recognize contentDocument.characterSet for an 
iframe element, but it is not writeable).

> Can, and if so how can, this particular warning be eliminated, by
> altering the beginning of the TXT file or by altering the displaying
> page/script or both?

It can be eliminated by saving the plain text document as UTF-8 encoded 
with BOM. This makes browsers auto-recognize it as UTF-8 encoded even in 
the absence of HTTP headers. Of course, any processing of the data then 
needs to skip the first three bytes in the file.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

TXT file into Iframe causes warning Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-12-25 12:03 +0000
  Re: TXT file into Iframe causes warning "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-12-26 10:00 +0200
    Re: TXT file into Iframe causes warning Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-12-27 20:20 +0000
  Re: TXT file into Iframe causes warning "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-02 07:34 -0800

csiph-web