There are times that you will need to run JavaScript from within a WATIR test. Usually the script that you will need to run will be contained inside a JavaScript function on the page. However, there are also instances whenever you simply need to run your own custom JavaScript specific to your test from your test script. To do this from WATIR is actually somewhat straightforward.
For example, if you want to add some text inside of an element with the id myElement then you could run the following.
ie.ie.Document.parentWindow.execScript("document.all['myElement'].innerHTML=\"Content\"")
You can use the same example above to run your JavaScript functions, simply add your functions name inside the execScript quotes.