Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>HTML Generator task</title>
  4.  
  5. <style>
  6. body{
  7. visibility: visible;
  8. }
  9. </style>
  10. </head>
  11. <body>
  12. <div id="wrapper"></div>
  13. <div id="book"></div>
  14. <!--
  15. <script src="script.js"></script>
  16. -->
  17. <script type="text/javascript">
  18.  
  19.  
  20. window.HTMLGen = function() {
  21.  
  22. }
  23.  
  24.  
  25. HTMLGen.createLink = function(id, text, url){
  26. var theATag = document.createElement('a');
  27. var linkText = document.createTextNode(text);
  28. theATag.appendChild(linkText);
  29.  
  30. theATag.href = url;
  31.  
  32. var element = document.getElementById(id);
  33. element.appendChild(theATag);
  34. }
  35.  
  36. HTMLGen.createDiv = function(id, aClass){
  37. var theDiv = document.createElement('div');
  38. theDiv.className = aClass;
  39.  
  40. var element = document.getElementById(id);
  41. element.appendChild(theDiv);
  42. }
  43.  
  44. HTMLGen.createParagraph = function(id, text){
  45. var theParagraph = document.createElement('p');
  46. var theTextNode = document.createTextNode(text);
  47.  
  48. theParagraph.appendChild(theTextNode);
  49.  
  50. var element = document.getElementById(id);
  51. element.appendChild(theParagraph);
  52. }
  53.  
  54. document.onload = function loadHTML(){
  55. window.location = 'CreateHTMLGeneratorObject.html';
  56. };
  57.  
  58. HTMLGen.createLink('book', 'C# basics book', 'http://www.introprogramming.info/');
  59. HTMLGen.createDiv('wrapper', 'section');
  60. HTMLGen.createParagraph('wrapper', 'Soft Uni');
  61.  
  62.  
  63. </script>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement