Reputation: 21
My button does not work for my website I am developing right now, I did the exact same thing for my other buttons. But just on that specific page my buttons won't work.
<head>
<link rel="stylesheet" href="bestelling.css" />
<link rel="shortcut icon" href="#">
</head>
<script>
function Aanvaarden()
{
window.location.assign=("Welcome.php")
}
function Annuleren()
{
window.location.assign=("Annuleren.php")
}
</script>
<br>
<input class="MyButton" type="button" value="Aanvaarden" onclick="Aanvaarden()" />
<input class="MyButton" type="button" value="Annuleren" onclick="Annuleren()" />
this is my code behind my buttons, what do I need to do?
Upvotes: 1
Views: 54
Reputation: 147
Remove the equal to sign after "assign". Your code should now work with the revision below.
function Aanvaarden() { window.location.assign("Welcome.php") } function Annuleren() { window.location.assign("Annuleren.php") }
Upvotes: 1
Reputation: 943214
window.location.assign
is a function.
Assigning a string to it (with =
) will just remove the function and replace it with a string.
It will have no visible effect unless some other code tries to call assign
, at which point it will throw an error because it isn't a function.
To use it, you should call the function and pass an argument:
window.location.assign("Annuleren.php")
That said, a regular link instead of a button with some JavaScript would almost certainly be a better, easier, more accessible solution.
Upvotes: 3