Java external script for the html page is not working

1

I have a problem with my pages after trying to put js in an external file it just stopped working, and I could not find the error so far.

Follow the codes

HTML

<script type="text/javascript" src="funcjs.js"></script>//dentro da tag head
<a href="javascript:showhide('login')" style="float:right;" >Login</a>//dentro da tag body

JS (inside the funcjs.js file)

Initially it was like this:

function showhide(id) {
   var e = document.getElementById(id);
   e.style.display = (e.style.display == 'inline') ? 'none' : 'inline';
}

but after researching and finding this: The HTML page is not" calling "JavaScript

stayed like this

showhide = function (id) {
   var e = document.getElementById(id);
   e.style.display = (e.style.display == 'inline') ? 'none' : 'inline';
}

When the 1 JS code was on the html page itself it was working normally, I did not make any changes to the html code after the change, is there anything wrong in the way I'm trying to call this function?

EDIT: FOLLOW THE HEAD OF THE COMPLETE CODE AS WELL AS DIV SHOWHIDE

HEAD

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,user-scalable=no">
<link href='https://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="funcjs.js"></script>
<script src='https://www.google.com/recaptcha/api.js?hl=pt-BR'></script>

DIV

<div id="login" style="display:none;">
            <form action="login.php" method="POST" enctype="multipart/form-data">
                <p><input type="text" name="usuario" id="usuario" placeholder="Usuário"></p>
                <p><input type="password" name="senha" id="senha" placeholder="Senha"></p>
                <p><input type="submit" value="login" id="entrar"/></p>
                <input type="hidden" name="entrar" value="login">
                <p value="error" style="display:none;">por favor preencha os campos!</p>
            </form>
</div>

OBS: I use this script on almost every page, and the only thing they share is the head, and none of them worked after putting the code in the external file.     

asked by anonymous 30.10.2017 / 15:30

1 answer

1

Hello. As the test I did is working normally its function. The example that shows in The HTML page is not "calling" JavaScript shows that the external .js file was called inside the / js folder. The example I made to simulate your situation was with all the files inside the same folder and I added the div with the id = 'login' that was not included in your example.

Make sure that the correct path of your .js file is referenced correctly; Make sure that the element with the id = 'login' exists.

    
30.10.2017 / 16:25