It does state on beforeload you can use scriptcont...
# suitescript
k
It does state on beforeload you can use scriptcontext.form. Maybe that would be the way.