0
I have a page with save button, but every time it is clicked the script appears that the information has been saved and leaves the page. My goal is that he doesn’t leave, but I looked at the code and I didn’t understand why it was coming out. Follow the button:
<div class="row">
<div class="col-md-6 botao">
<button type="submit" class="btn btn-primary form-control" name="button" id="button">Salvar</button>
</div>
<div class="col-md-6 botao" >
<button type="button" name="button" id="button" class="btn btn-danger form-control">Cancelar</button>
</div>
Follows the Script:
<script>
var retorna = function () {
window.location = "a_pagina_anterior.php";
}
var button = document.querySelector("#button");
button.onclick = retorna;
</script>
Are some chunk of code missing ? As far as I remember history is not a function, history you can call back() and forward()
– Mateus Veloso
No. I use sublime text and it accuses when something is recognized or not as a function. I was trying to use window.history.back()
– Mariana Bayonetta
Open a console in some browser and type window.history()
– Mateus Veloso
Actually, it’s not a function. But I don’t understand why my window.history.back() doesn’t work.
– Mariana Bayonetta
Now yes kkk, your back doesn’t work ?
– Mateus Veloso
Repeat your question again so I can help you better.
– Mateus Veloso
Right. When my save button is clicked, the page returns to the previous one. The code in jscript is this one, I looked several times and it seems all right, I even tried to disable the script but it keeps happening the same.
– Mariana Bayonetta
Mariana, the code you are using is really what is in the question? review the code
– Mateus Veloso
Opa. correction, window.history.back() no, window.history.forward()
– Mariana Bayonetta
Code you posted from error because it uses history as Function.
– Mateus Veloso
Ah, you’re right, the code is wrong. That’s the code I’ve already touched until I say enough, I’ll edit to the original.
– Mariana Bayonetta
All right, as soon as you change communicate, try to put the whole code ok?
– Mateus Veloso