Javascript function does not run Online

Asked

Viewed 356 times

-1

The code below only works on localhost , online does not work, that is, it works perfectly on my machine, when I transfer to the server , none of it works, I already broke my head and could not solve.

DETAIL! - The arquivo.js is within the root directory of http://loacalhost no intermediate paths, note:

<script type="text/javascript" language="javascript" src="arquivo.js"></script>
<script type="text/javascript" language="javascript" src="/arquivo.js"></script>
<script type="text/javascript" language="javascript" src="../arquivo.js"></script>

I performed local tests, with the three types mentioned above and all did well. Already in the server http://xpg.uol.com.br I have done likewise leaving it at the root, but without success.

In a new attempt, I included the content of arquivo.js within the HTML document (page index.html), even so, no chance.

In another attempt with absolute path, related to server configuration, where:

<script type="text/javascript" language="javascript" src="http://meusite.xpg.uol.com.br/arquivo.js"></script>

.. legal funf when put in localhost otherwise ... no way.

Anyway, it seems to me to be in the scope of the function or even in the placement of the same on the page.

I would like to understand where I am going wrong. I thank you from now on, help from all.

  • It has to do with relative paths and server configuration, to solve this use absolute path, i.e.: www.meusite.pt/public/js/bootstrap.js

  • How is the url in import production?

  • Hello, On putting in the same page folder and using <script type="text/javascript" language="javascript" src="file.js"></script> does not work? what is the error in the console?

  • If you’re using Chrome, press F12 and see if there’s a white x dot showing errors, click on it and say what appears.

1 answer

0


To all who commented in short answer to the question, I reached the conclusion. It was necessary to change the following lines:

wrong onclick="nome(txt)"

removed the txt it was not necessary to refer to <input type="text" id="txt"/>, and stayed like this:

onclick="nome()"

also:

wrong document.all.id.value;

that now, is written so:

document.getElementById('id').value;

Ready!

For reasons I do not know, after modifying, the Javascript function it started to work so much on the side Client how much on the side Sevidor.

Browser other questions tagged

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