Reputation: 131
I have looked on here and around the internet for over 5 hours and I cannot figure out what I am doing wrong. It is probably something really simple. Here is my code so far:
<script type='text/javascript'>//<![CDATA[
window.addEvent('load', function() {
document.getElementsByClassName('submitformlisting')[0].onclick = function(){
window.btn_clicked = true;
};
window.onbeforeunload = function(){
if(!window.btn_clicked){
return 'If you leave now, your information will be lost.';
}
};
});//]]>
</script>
And my submit button looks like this:
<input type="submit" name="submit" id="submitformlisting" class="id="submitformlisting"" value="Add Listing" tabindex="4" onclick="return doSubmit();" />
Upvotes: 0
Views: 49
Reputation: 382160
You messed the class in your html. Change class="id="submitformlisting""
to class="submitformlisting"
.
But you'd better use the id instead of the class.
Change
document.getElementsByClassName('submitformlisting')[0].onclick = function(){
to
document.getElementById('submitformlisting').onclick = function(){
Upvotes: 4