Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25665
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Override mimetype when loading javascript dynamically? |
| Date | Sat, 09 Aug 2014 16:11:30 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 34 |
| Message-ID | <1705878.HnaZ2UrlZN@PointedEars.de> (permalink) |
| References | <b8d21a27-0014-4054-886e-44157421f3d5@googlegroups.com> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1407593491 32294 eJwFwYEBwCAIA7CXkNKC52wK/59gQmjpZIgKDge5Y5eYTVDrK/QU2w/c/vGMua4YS8Ci6z79AhAo (9 Aug 2014 14:11:31 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Sat, 9 Aug 2014 14:11:31 +0000 (UTC) |
| User-Agent | KNode/4.12.4 |
| X-User-ID | eJwNxsEBwCAIA8CVQCXAOIhk/xHae51tKNoPDMdoPMLqvDna4aI3ajzKvZKXDFmjMU2Byjz589CyYfbGk8s+cY8WKw== |
| Cancel-Lock | sha1:UP6XjyZKAPjwoDmxgN6cd/8nZa4= |
| X-NNTP-Posting-Host | eJwFwQkRwDAIBEBLAe5p5QSm+JfQXZZCY4gClws9yjzfwj63udHDCrHXc4kypQAZfk93/gWoEA0= |
| Xref | csiph.com comp.lang.javascript:25665 |
Show key headers only | View raw
Me Self wrote:
^^^^^^^
> I'm trying to load some javascript dynamically using the code snippet
> below.
There is no javascript; see my sig.
> Unfortunately the server (which is outside my control) hosting the src is
> sending the script as MIME type "text/html" instead of
> "application/javascript" causing Chrome to fail with this message
> "Resource interpreted as Script but transferred with MIME type
> text/html:".
>
> Is it possible on the client side to convince Chrome that it should
> consider it "application/javascript"?
No, you need to solve this server-side.
> var s = document.createElement("script");
> s.type = "text/javascript";
> s.src = "https://.....";
> document.getElementsByTagName("head")[0].appendChild(s);
Since the HTML5 API there is “document.head” as a shortcut for
“document.getElementsByTagName("head")[0]”.
Please get a real name and do not post via the borken Google Groups.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Override mimetype when loading javascript dynamically? Me Self <wmsopou@gmail.com> - 2014-08-09 06:43 -0700 Re: Override mimetype when loading javascript dynamically? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-09 16:11 +0200 Re: Override mimetype when loading javascript dynamically? Andreas Bergmaier <andber93@web.de> - 2014-08-10 22:44 +0200 Re: Override mimetype when loading javascript dynamically? Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-10 21:57 +0000
csiph-web