How to include a js from another domain in html?

Asked

Viewed 62 times

2

Hello, I have a file . js on http://meudominio.com/arquivo.js. I would like to call you elsewhere (meudominio2.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?

2 answers

4

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

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

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>

Browser other questions tagged

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