On Monday 05 March 2007 13:56, smeranda wrote: > Still no luck, this is what I have: > > $("a").click(function(){alertSave($(this).attr("href"));}); > > function alertSave(url) { > var dataControl = $('#changedAppointments').attr("value"); > if (dataControl.length > 0) { > if (confirm("You have made changes to this date which have not been > saved.\n\nAre you sure you want to navigate from this page?")) { > document.location = url; > } else return false; > } > } > > James Thomas wrote: > > You need to return false if you don't want something to happen. so if > > (confirm('whatever')) { do_whatever(); } else return false; > > > > smeranda wrote: > >> When a user clicks a link and a form field currently has data, a > >> confirmation box appears. This is close to working, but if a user clicks > >> 'cancel' the browser still redirects to the a href URL. What am I doing > >> wrong? > >> > >> $("a").click(function(){alertSave($(this).attr("href"));}); > >> > >> function alertSave(url) { > >> var dataControl = $('#changedAppointments').attr("value"); > >> if (dataControl.length > 0) { > >> if (confirm("You have made changes to this date which have not > >> been > >> saved.\n\nAre you sure you want to navigate from this page?")) { > >> document.location = url; > >> } > >> } > >> }
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/