Reputation: 1779
I want to relocate on button click to a relative url:
<button onclick="document.location.href='/Recruiters.aspx'"></button>
but this is not working...
Any suggestions?
Upvotes: 3
Views: 11804
Reputation: 140228
The default type
of a button is "submit"
so when inside a form, clicking the button submits it. Though it should first redirect but it's worth a shot:
<button type="button" onclick="document.location.href='/Recruiters.aspx'"></button>
Upvotes: 6
Reputation: 28737
Your onclick needs to be a handler. You could do it like this:
<script>
function redirect()
{
window.location.href='/Recruiters.aspx';
}
</script>
<button onclick="redirect()"></button>
If you don't want to use a handler you can still do it inline like this:
<button onclick="javascript: window.location.href='/Recruiters.aspx';"></button>
Upvotes: 0