Hello, I am relatively new to javascript although I have used some over recent years in my html web pages. I have a specific problem in which I have a form with an input box that I must validate as true or false. This part works. The call to another javascript will only work if tagged as target="_blank". I want to open the new url in the same window and nothing I have found on internet has worked.
Here is my code:
<script type="text/javascript"> function gotoProductWebPage() { var answer = document.getElementById("answer").value; if(answer==8){ nowbaby(); return true; } else { alert("Check your Math"); return false; } } </script>
<Script type="text/javascript"> function nowbaby() { window.open ("myurl,"_self",false); }
and here is the call from form:
<form method="get" name="myname" onsubmit="gotoProductWebPage()">
and here is html snippet:
<p style='color:blue;text-align:center' > Enter answer to prove you are human. A=3, B=5, A+B=<input type="number" id="answer" size="6" name="answer" /><br /> </p> <p align='center' > <input type="submit" name="Submit" value="Submit" /> </p>
Like I said, if I make it _blank it will open in new window, but for the life of me, I cannot get it open in same window.
I have tried:
window.location.href = "myurl"
window.open("myurl/pid='0000","_self")
location.ref
and nothing seems to work. I am stumped. Please Help.
I am working in IE and Edge, sorry should have referenced that.