How to include a js from another domain in html?

2

Hello, I have an .js file in link . I would like to call it in another location (mydomain2.com) with <script src="meudominio.com/arquivo.js" ></script> , however, gives file not found. And the name is correct and I can access it through the browser. So the question is this: how to include this .js so that I can work with it on another page?

    
asked by anonymous 03.03.2016 / 20:22

2 answers

3

Specify the protocol

A generic mode where it becomes compatible with https and http:

<script src="//meudominio.com/arquivo.js" ></script>

If you want a specific protocol

<script src="http://meudominio.com/arquivo.js" ></script>
    
03.03.2016 / 20:25
4

To import any file on the web, the file must first be on the internet.

I also noticed that you wrote <script src="meudominio.com/arquivo.js" ></script> , forgetting the link , try inserting: <script src="http://meudominio.com/arquivo.js" ></script>

    
03.03.2016 / 20:27