starbucks
starbucks

Reputation: 3016

How do I make local js files work?

ON my local I am testing out stuff I've built.

This is the script I am trying to include in a file in the same folder:

<script src="/colorpicker/js/evol.colorpicker.min.js" type="text/javascript" charset="utf-8"></script>

The colorpicker is on my desktop in a folder called Work/demo/

The colorpicker is not working. What an I do to make it work on my local?

Upvotes: 2

Views: 78

Answers (2)

SaidbakR
SaidbakR

Reputation: 13534

Since The script file is in the same folder with your HTML page, so you just have to include it with its file name only:

<script src="evol.colorpicker.min.js" type="text/javascript" charset="utf-8"></script>

Upvotes: 0

Quentin
Quentin

Reputation: 943207

There are a number of things (but mostly XMLHttpRequest) that can be done using JavaScript that will be blocked from file:/// URIs for security reasons in some browsers. In general, for development purposes, I strongly recommend installing a web server (either directly on your workstation or in a virtual machine) and using that for testing.

That said, if you do want to test without a web server, then don't use root relative URIs. i.e. Do not start your URIs with a / character as that will hit the top of your file system, not the top directory that you consider to be part of your site.

Upvotes: 4

Related Questions