Wednesday, September 12, 2007

How to force users to print using Spry

You can't actually force users to print but you can have the browser's print dialog displayed using a simple, properly placed JavaScript command. The JavaScript I'm referencing is "window.print()", which could be launched on submit if it weren't for the form validation which it will conflict with.

If you are using the Spry Framework to assist with form validation you can place the window.print() command in the Spry JavaScript file such as, SpryValidationSelect.js in the Spry.Widget.ValidationSelect.prototype.validate function immediately before the return true. This will cause the print dialog to display only if the input passes validation.

1 comment:

Unknown said...

Thanks a ton.. I was wracking my brains trying to figure this one out.

Cheers, and keep the flow of info coming!