demo.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2. <html><head>
  3. <script src="../src/prettify.js"></script>
  4. <script src="../src/lang-css.js"></script>
  5. <style>
  6. body { margin: 0; padding: 0 }
  7. pre { margin: 0 }
  8. </style>
  9. </head>
  10. <script>
  11. // This page displays some code styled using a theme named in the
  12. // query part of the URL.
  13. var themeName = decodeURIComponent(document.location.search.replace(/^\?/, ''));
  14. // Call out to the parent so that it can resize the iframe once this
  15. // document's body is loaded.
  16. function adjustHeightInParent() {
  17. if (parent !== window) {
  18. try {
  19. var div = document.body.getElementsByTagName('div')[0];
  20. parent.adjustChildIframeSize(
  21. themeName, div.offsetWidth, div.offsetHeight);
  22. } catch (ex) {
  23. // Can happen when this page is opened in its own tab.
  24. }
  25. }
  26. }
  27. // Load the necessary CSS
  28. (function () {
  29. document.title = 'Theme ' + themeName;
  30. // Load the stylesheet that we're demoing.
  31. var link = document.createElement('link');
  32. link.rel = 'stylesheet';
  33. link.type = 'text/css';
  34. link.href = themeName === 'default'
  35. ? '../src/prettify.css' : themeName + '.css';
  36. document.getElementsByTagName('head')[0].appendChild(link);
  37. })();
  38. </script>
  39. <body onload="prettyPrint(); adjustHeightInParent()">
  40. <div style="width: 40em; display: inline-block">
  41. <pre class="prettyprint lang-html linenums">
  42. &lt;script type="text/javascript"&gt;
  43. // Say hello world until the user starts questioning
  44. // the meaningfulness of their existence.
  45. function helloWorld(world) {
  46. for (var i = 42; --i &gt;= 0;) {
  47. alert('Hello ' + String(world));
  48. }
  49. }
  50. &lt;/script&gt;
  51. &lt;style&gt;
  52. p { color: pink }
  53. b { color: blue }
  54. u { color: "umber" }
  55. &lt;/style&gt;
  56. </pre>
  57. </div>
  58. </body></html>