When using , where the URL refers to a plain text file, is there a way to access the content
First of all, the textattribute of the HTMLScriptElement is the preferred method to access the text of an inline element. DOM-Level-2 and HTML5: 4.11.1 both indicate that a script should have an attribute text which contains the scripts interior text:
The IDL attribute
textmust return a concatenation of the contents of all the Text nodes that are children of thescriptelement (ignoring any other nodes such as comments or elements), in tree order. On setting, it must act the same way as thetextContentIDL attribute.
Since the element is empty (you specified an external source), text, textContent and innerHTML are empty. This is because the text attribute is only set in inline scripts:
If the script is inline and the script block's type is a text-based language:
The value of the
textIDL attribute at the time the element's "already started" flag was last set is the script source.
So it's not possible to include an external text/plain using this method.
See also: