Reputation: 987
Have a look on this site: https://bm-translations.de/impressum-agb-datenschutz.php
I am loading external scripts and sheets. Everything is working except the globaljs.js
file. I cannot see errors. Its in the same directory as the site.
I uploaded it as text as well, so you can have a look on it: https://bm-translations.de/globaljs.txt
What am I doing wrong? I tried to implement the script in the head, as you can see, as well as at the end of the body. The JS works perfectly within the page, but as soon as I try to outsource it as external script, its not working anymore.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="globalcss.css">
<meta charset="UTF-8">
<link rel="shortcut icon" href="./bilder/favicon.ico"/>
<link rel='dns-prefetch' href='//fonts.googleapis.com' />
<!--jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.lazyload/1.9.1/jquery.lazyload.min.js"></script>
<script src="globaljs.js"></script>
Upvotes: 1
Views: 631
Reputation: 105
Be sure your JavaScript file is in the same directory as the .html or .php file that is calling for the script.
For instance, if your directories look like this:
pages
..index.php
scripts
..globaljs.js
Your HTML would need to reflect the directory structure like
<script type="text/javascript" src="../scripts/globaljs.js"></script>
Without knowing your directory structure it is difficult to say.
Upvotes: 1