I know that similar questions have been asked but after various tests, no one seem to work. I think it has to do something with the fact I try to redirect from a local html file to another local html file using js.
Button in my creationPage.html:
<form>
<button id="createChar">Create character</button>
</form>
Code in my js file for redirect:
var Create = document.getElementById('createChar');
Create.addEventListener("click", function() {
//window.open(url); //opens in a new tab, WHICH IS NOT DESIRED !!!
//window.location.replace(url); //doesnt work either.
var url = "http://localhost/myprojects/L2/selectYourCharacter/test.html";
window.location.href = url;
return false;
});
I want to stick with addListenerEvent as it's best practice. If I run window.open(url, "_blank")
, it doesnt work.
Summary: I want to redirect via my Button located in http://localhost/myprojects/L2/charCreation/creationPage.html to http://localhost/myprojects/L2/selectYourCharacter/selectYourCharacter.html staying in the same window.
Thanks a lot for your help as I have been stuck with this for hours...
Note: The window.open("www.youraddress.com","_self") doesn't work and I think it's because my files are running on localhost.