I have developed the following function to open an email with the html form contents in the body and also redirect the web page to a "Thank You" page. My problem is, window.location.href will only read once (whichever the last call is) and ignore the first one. If I change one to window.open(), the function works but then I have a new page open and my task is to not have a new browser page open.
I have tried to next functions and setTimeout(function()) to no avail. I probably did not implement them correctly though.
Here is where I call the function in my html:
<input class="buttonRequest" type="submit" value="Submit Request" onclick="OnButton1(); return false">
Here is my Javascript:
function OnButton1() {
var email = "mailto:emailAddress@email.com"
+ "&subject=" + "Access Request"
+ "&body=" + $("#userName").val()
+ $("#user-email").val()
+ $("#ID").val()
+ $("#command").val()
+ $("#orgCode").val()
+ $("#selectStyle").val();
var newPage = "ThankYou.html";
window.location.href = newPage;
window.location.href = email;
}