Q:

Javascript Button Redirect

Trying to get my button to act like a link (tried the <A> tag and it would work if you open in a new tab but not if you click on it. Then tried this code and nothing.  Suggestions?
<button onClick="location.href='/secure/edit.aspx?id=671'">Edit</button>

A:

You need to explicitly say window.location because this in the context of the button is the button object itself. Ordinarily, JavaScript is run in the context of the window object, so you don't need to do that.
<button onClick="javascript:window.location.href='/secure/edit.aspx?id=671'">Edit</button>

(Additionally, I also like to explicitly state that the script is javascript:, but that's purely a personal thing.)

A:

<button onclick="window.location='/secure/edit.aspx?id=671'">Edit</button>

