How to make w3schools like tryit editor?
Just copy and paste this code and modify it according to your needs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
<?php include "../../tryheader.php"; ?> <html> <head> <style type="text/css"> textarea, iframe { border: 2px solid green; width: 100%; height: 500px; } </style> <title>Background-Image in HTML and CSS</title> <meta name="description" content="Background-Image in HTML and CSS"> <meta name="keywords" content="Background-Image in HTML and CSS"> </head> <body> <h1>Background-Image in HTML and CSS</h1> <table width="100%" cellspacing="4" cellpadding="4"> <tr> <td width="50%" scope="col"> </
td> <td width="50%" align="left" scope="col"> <input onclick="runCode();" type="button" value="Run run"> </td> </tr> <tr> <td> <form> <strong>SourceCode</strong> <textarea name="sourceCode" id="sourceCode"> <html> <head> <style> body { background-image: url("logo.jpg"); } </style> </head> <body> <p>This page has an image as the background...</p> </body> </html> </textarea> </form> </td> <td><strong>Output</strong><iframe name="targetCode" id="targetCode"></iframe></td> </tr> </table> <script type="text/javascript"> function runCode() { var content = document.getElementById('sourceCode').value; var iframe = document.getElementById('targetCode'); iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument; iframe.document.open(); iframe.document.write(content); iframe.document.close(); return false; } runCode(); </script> </body> </html> <?php include "../../tryfooter.php"; ?> |