如何在html(php)文件中加载javascript文件

时间:2022-01-24 00:12:55

So I have little bit html on the footer.php and I cannot load the javascript files

所以我在footer.php上有一些html,我无法加载javascript文件

Footer.php

Footer.php

        <footer>
            Test
        </footer>
        <script src="./assets/js/jquery-2.2.4.min.js" type="text/javascript"></script>      
        <script src="./assets/js/bootstrap.min.js" type="text/javascript"></script>     
        <script src="./assets/js/npm.js" type="text/javascript"></script>
        <script src="./assets/js/test.js" type="text/javascript"></script>
    </body>
</html>

So when I see on the network on the browser I see the four js files is load like type html.

因此,当我在浏览器上看到网络时,我看到四个js文件的加载类似于html。

如何在html(php)文件中加载javascript文件

I used the Eclipse for PHP developers. How can I make the javascript files is load like javascript files not like html files.

我将Eclipse用于PHP开发人员。如何使javascript文件加载像javascript文件不像html文件。

When is load is have the mistake for every js file.

何时加载对每个js文件都有错误。

SyntaxError: expected expression, got '<'

SyntaxError:期望表达式,得到'<'

Edit: Index.php I not have any logic.

编辑:Index.php我没有任何逻辑。

Index.php

的index.php

    <?php 
    include 'views/elements/header.php';
?>

<?php 
    include 'views/elements/footer.php';
?>

In header I don't have any php or html code

在标题我没有任何PHP或HTML代码

EDIT:

编辑:

I find my problem is in .htaccess. This is my .htaccess file and when I delete then is working.

我发现我的问题在.htaccess。这是我的.htaccess文件,当我删除然后工作。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUIEST_FILENAME} !-d
    RewriteCond %{REQUIEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

could some one tells me how can make .htaccess to working correct. Or some link from where can I see how to configurate the .htaccess file.

可能有人告诉我如何使.htaccess工作正确。或者从哪里可以看到如何配置.htaccess文件的链接。

1 个解决方案

#1


1  

Here is the .htaccess i use on my site to redirect all /tds/tre to the index except when called url is a directory or file.

这是我在我的网站上使用的.htaccess将所有/ tds / tre重定向到索引,除非被调用的url是目录或文件。

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?syst=$1 [QSA,L]

#1


1  

Here is the .htaccess i use on my site to redirect all /tds/tre to the index except when called url is a directory or file.

这是我在我的网站上使用的.htaccess将所有/ tds / tre重定向到索引,除非被调用的url是目录或文件。

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?syst=$1 [QSA,L]