简体   繁体   English

不加载外部js脚本

[英]not loading external js script

Have a look on this site: https://bm-translations.de/impressum-agb-datenschutz.php I am loading external scripts and sheets.看看这个网站: https : //bm-translations.de/impressum-agb-datenschutz.php我正在加载外部脚本和工作表。 Everything is working except the globaljs.js file.除了globaljs.js文件外,一切正常。 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我也把它作为文本上传,所以你可以看看它: 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. JS 在页面内完美运行,但是一旦我尝试将其外包为外部脚本,它就不再工作了。

<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>

Be sure your JavaScript file is in the same directory as the .html or .php file that is calling for the script.确保您的 JavaScript 文件与调用脚本的 .html 或 .php 文件位于同一目录中。

For instance, if your directories look like this:例如,如果您的目录如下所示:

pages
  ..index.php
scripts
  ..globaljs.js

Your HTML would need to reflect the directory structure like您的 HTML 需要反映目录结构,如

<script type="text/javascript" src="../scripts/globaljs.js"></script>

Without knowing your directory structure it is difficult to say.不知道您的目录结构就很难说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM