I have a site that has the fixed side menu and the other part loads the pages. For each page of the site I made a js file. For example: Home.jsp I have the file home.js, Contacts.jsp I have the contacts.js.
I'm loading the pages with the jquery .load('Home.jsp')
command. What happens is that when I open the Home page, the files are loaded normally, however when I open the Contacts, the Home js conflicts with the Contacts js. The conflict occurs because there are functions with the same name, but imagined that overlapping a page with the other 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>
menu.js
$(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);
}
contact.js
function carregaFundo(){
$("#fundo").show(200);
}
When I call home.jsp and then the contact.jsp, when loading the contact.jsp, the function loadFl () is called twice, that is, once for the home.js file and once for the file contact.js