The only way to write business logic for the browser-enabled forms is by doing it in .NET (it will get executed on the server). Forms developed this way will seamlessly work both in the Forms Server and the rich InfoPath client.
However, although there is no direct way to run Javascript from a browser-enabled form, you can host your form in a custom ASPX page and you can run your script there.
Note that interacting with the form in Javascript is not supported so your options of what you can do are pretty limited. Here is a blog post on hosting your form in a custom page:
http://blogs.msdn.com/infopath/archive/2006/10/21/hosting-infopath-forms-in-a-custom-aspx-page.aspx
David Airapetyan / Software Services ArchitectQdabra® Software / Streamline data gathering to turn process into knowledge