FWIW, the ASP.Net function Page.RegisterStartupScript places the registered script at the bottom of the page, after all controls. That seems like a logical place to do it since, as you note, the JS ...
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する