require 'watir'
ie = Watir::IE.new
ie.goto(" http://www.google.cn")
ie.document.parentWindow.execScript("alert(\"测试调用Javascript!\");")
or
ie.document.getElementById('txtUsername').readOnly = true
or
js = %{ie.document.getElementById('txtUsername').readOnly=true}
ie.document.parentWindow.execScript(js)