Load script before document load

Load script before document load

I'm trying to address the issue with Facebook OAuth as described at the bottom of  http://jquerymobile.com/test/docs/pages/page-navmodel.html.

On a registration page I have a "Sign in with Facebook" button. When I click it I get a "Page Load Error".

Added to the registration page:
  1.     <div data-role="page" id="register">
  2.       <script>
  3.         $("#register").live('pageinit',function() {
  4.           if (window.location.hash == "#_=_")
  5.             window.location.hash = "";
  6.         });
  7.       </script>
  8.     </div>

but that didn't make a difference. Any ideas how/where this should be loaded?

Thanks.