html - Check if link is clicked in JavaScript -
edit: question different 'supposedly duplicate' because mine checking how not trigger off event when link clicked, other question how detect changes in form.
i using function (taken here) detect changes made form before leaving page, works fine triggers off when click save button using onbeforeunload
event fire of function , want prevent happening when click save button.
here event:
window.onbeforeunload = function (e) { e = e || window.event; if (formisdirty(document.forms[0])) { // ie , firefox if (e) { e.returnvalue = "you have unsaved changes."; alert("you have unsaved changes."); } // safari return "you have unsaved changes."; alert("you have unsaved changes."); } };
how can prevent event firing when particular save link clicked?
link:
<a id="ctl00_contentplaceholder1_lbtnsave" href='/save'> <img id="ctl00_contentplaceholder1_image5" class="imgvalign" src="../../images/icons/save.gif"> save </a>
event.target //dom object. event.target.id //id of source element. sourceelement = $(event.target.id); // jquery object
you can check element submit button or not.if yes no need display message
Comments
Post a Comment