Reputation: 13347
I know this is a stupid question.
But just out of curiosity, is there a way to post an html file(a .html file) as a js/css file (renamed as .js or .css) with the type header as either HTML or js/css and get the data at the browser end in normal html format? I mean the browser reading it as an html itself and display it as any other html page?
Upvotes: 1
Views: 79
Reputation: 1039438
What matters for the browser when displaying a resource is the Content-Type HTTP header. As long as this header is set by the web server to text/html
, the extension doesn't really matter. The resource will be interpreted as HTML. So you could configure the web server to serve .js file with a text/html
Content-Type and it will work.
The file doesn't even need to exist on the server. That's why I prefer to talk about resources instead of files. You could use a server side language and configure it to respond to some virtual address (with the .js
extension) and serving HTML content with the text/html
Content-Type header.
Upvotes: 6