Guest User

Untitled

a guest
Nov 18th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Home</title>
  5. </head>
  6. <body>
  7.  
  8. hello world
  9.  
  10. <script>
  11. const href = window.location.pathname;
  12. const chunkIndex = href.lastIndexOf('/');
  13. const path = href.slice(0, chunkIndex + 1);
  14.  
  15. function appendScripts() {
  16. const script = document.createElement("script");
  17. script.src = path + "scripts.js"; // use this for linked script
  18. document.body.appendChild(script);
  19. }
  20.  
  21. function appendCSS() {
  22. link=document.createElement('link');
  23. link.href= path + 'styles.css';
  24. link.rel='rel';
  25. document.getElementsByTagName('head')[0].appendChild(link);
  26. }
  27.  
  28. document.addEventListener("DOMContentLoaded", function(event) {
  29. appendCSS();
  30. appendScripts();
  31. });
  32. </script>
  33.  
  34. </body>
  35. </html>
Add Comment
Please, Sign In to add comment