2
I have a site that has the fixed side menu and the other part is loaded the pages. For each page of the site I made a js file. For example: Home.jsp I have the home.js file, Contacts.jsp I have the contacts.js.
I am loading the pages with the jquery command .load('Home.jsp')
. What happens is that when I open the Home page, the files are loaded normally, but when I open Contacts, the js of the Home conflict with the js of Contacts. The conflict occurs because there are functions with the same name, but imagined that when overlapping one page with the other the js of the old would be "deleted".
Does anyone know if via JS I can effectively delete a JS file from the browser? Or if I have to clear some cache, or something like that.
Example:
Menu.jsp:
<div>
<div id="home">Home</div>
<div id="contato">Contatos</div>
</div>
js menu.
$(document).ready(function(){
$("#home").click(function(){
//.dconteudo è uma div onde jogo as páginas que serão exibida no site
$(".dconteudo").load("home.jsp")
});
$("#contato").click(function(){
//.dconteudo è uma div onde jogo as páginas que serão exibida no site
$(".dconteudo").load("contato.jsp")
});
});
Home.jsp
....
<head>
<script type="text/javascript" src="home.js"></script>
</head>...
Contact.jsp.
....
<head>
<script type="text/javascript" src="contato.js"></script>
</head>...
home js.
function carregaFundo(){
$("#fundo").show(200);
}
js contact.
function carregaFundo(){
$("#fundo").show(200);
}
When I call home.jsp and then contact.jsp, when loading the.jsp contact, the function loadFundo() is called twice, i.e., once for the home.js file and once for the contact.js file
If you can explain better the problem you have in particular and, if possible, show code you have done where this problem is. Your question is too broad, see Help Center How to Ask.
– Jorge B.
Strange to run twice... If the function is reset, it should run only once. Has some functional example link for us to see?
– bfavaretto
@bfavaretto I have no way to publish any example. But I also thought that the function would be redefined and would have no problem. But when I look at the Development Tool, I can access both JS. Even by "removing" the other page with the
.load
.– lionbtt