Not recognizing js file when it is in 2 folders

Asked

Viewed 666 times

0

Good my html is not recognizing the js file when I put in 2 folders for example, when I put

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

It doesn’t work even the file being there, then I moved the file only to js/scripts.js and it worked normally, someone can tell me what is causing it.

http://i.imgur.com/enC4JX2.png

PS: Ali ta asssets, with 3 "S", but I put wrong only at the time of taking print even.

  • "PS: Ali ta asssets, with 3 "S", but I put wrong only at the time of taking print even."

  • Put "<script type="text/javascript" src="Assets/js/scripts.js"></script>" before the body closes, not outside it.

  • Still in the way desmo, not working...

  • I think you have not read the topic, it is a problem when calling it, when I put in js/scripts.js or the direct directory of the site works perfectly, now if I put in 2 folders, Assets/js/scripts.js does not work.

  • I just think I’d better read the question well before I answer, explain more that there’s no way, but thank you for answering.

1 answer

3


Tag <script type="text/javascript" src="assets/js/scripts.js"></script> before the body closes </body> instead of outside it before the </html>.

Exemplifying:

...
    <script type="text/javascript" src="assets/js/scripts.js"></script>
    <script>
        hideElement...
    </script>
</body>
</html>

OBS: It is no longer necessary to specify the type in the tags LINK and SCRIPT since you are using HTML5.

Staying:

<script src="assets/js/scripts.js"></script>

The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a Valid MIME type. The charset Parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".

Documentation: Scripting - W3 Recommendation

OBS: Also check your .htaccess. It may be blocking access to directories.

  • Still in the way desmo, not working...

  • I think you have not read the topic, it is a problem when calling it, when I put in js/scripts.js or the direct directory of the site works perfectly, now if I put in 2 folders, Assets/js/scripts.js does not work.

  • Yes, several times, I even changed the name of the Assets folder, but it still doesn’t work :/

  • Look, first in 2 folders aa/js http://prntscr.com/5yr7n5 result http://prntscr.com/5yr7tx then in 1 folder only, js/ http://prntscr.com/5yr83j result http://prntscr.com/5yr7z0

  • 1

    The code is correct, the path is correct. That . htaccess is blocking some directory?

  • Lol, it was the . htaccess, put Deny from all, but before I had taken and the error persisted, now pulled and is running noralmente, thank you very much.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.