I wonder, how can I display HTML content using Javascript, from what I know and been searching it’s simply not possible to do that.
But I have found a javascript code, that is displaying HTML content (not raw) when there is frame in the URL parameters.
Here it is:
http://otslist.eu/ratingWidget.js – Here you can find the raw javascript code.
http://otslist.eu/ratingWidget.js?frame=1 – And here it is displaying the HTML.
How is that possible? How to do something like that?
The JavaScript you see is a PHP script on the server. Use some browser/network debugger tool to check the HTTP response:
and see that it is powered by PHP. So it is the output of a PHP script and not a regular JavaScript document.
The PHP script outputs a JavScript when
frame=1is omitted.When the
frame=1is included, it tells the PHP script to embed the JavaScript into an HTML page and serve that.Update: The PHP script could look like this:
Note that I quickly typed this together, so it is probably full of errors. But it should give you the general idea.