I asked this question in the main SOF forum but I think it belongs here.


I need to add a little JavaScript to run when user clicks "Save and Close". I know in SharePoint 2010 I could just use PreSaveAction() but I am using 2003.


user clicks save and close
if attachment exists
  add the list entry
  alert the user to upload attachment

It looks like the function ClickOnce() is what triggers the form to save since the button href="javascript:ClickOnce()". So what I did was change the href of this link to my own function unless attachment exists. This did not work because it would either do nothing or fire when the page loaded whether there was an attachment or not.

Anyone have a workaround for this?

1 Answer 1


You could use jQuery to change the HREF on the save button to first call your javascript and then call the ClickOnce() function.

Something like:

  • This didnt work either. I think SharePoint javascript is running after mine and overwriting the href. May 2, 2012 at 17:56
  • Use a JavaScript timeout to set your HREF 200-300 MS after the page loads. That should give it enough time for SharePoint to do its thing, but quick enough that the user won't click the button before then. May 2, 2012 at 19:02
  • The timeout made it work. May 4, 2012 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.