Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.location.href for relative path

Tags:

javascript

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?

like image 224
David Van Staden Avatar asked Oct 30 '25 20:10

David Van Staden


1 Answers

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>
like image 152
Esailija Avatar answered Nov 02 '25 09:11

Esailija