Can I add custom attributes to button html. Will it work in all browsers
<pre><code>&lt;button id="save" custom-field="false"&gt;
</code></pre>

<p>Can I define my own custom attribute for button markup like stated above? Will it work on all browsers?</p>

<p>Basically, the problem I have is that the above save button redirects to an AJAX call, which, if successful, then redirects to some other page.
I have added an alert on window.onbeforeunload. I don't want this alert to pop up when the redirect is due to successful ajax call on click of the save button.</p>

<p>So, the above fix is that on successful ajax, I set the <code>custom-field</code> to true and in my window.onbeforeunload code I alert only if <code>custom-field</code> false.</p>