Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Home</title>
- </head>
- <body>
- hello world
- <script>
- const href = window.location.pathname;
- const chunkIndex = href.lastIndexOf('/');
- const path = href.slice(0, chunkIndex + 1);
- function appendScripts() {
- const script = document.createElement("script");
- script.src = path + "scripts.js"; // use this for linked script
- document.body.appendChild(script);
- }
- function appendCSS() {
- link=document.createElement('link');
- link.href= path + 'styles.css';
- link.rel='rel';
- document.getElementsByTagName('head')[0].appendChild(link);
- }
- document.addEventListener("DOMContentLoaded", function(event) {
- appendCSS();
- appendScripts();
- });
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment