From: Michael Neumann Date: 2007-01-14T19:59:40+09:00 Subject: Re: [ANN] RubyJS - Convert Ruby to Javascript Am Sonntag, 14. Januar 2007 09:05 schrieb Une B�vue: > Michael Neumann wrote: > > With RubyJS you can transform a subset of Ruby into Javascript code. > > yes but how to interact with the browser window, for example, say i have > a : > >
 in the html document and i want to redefine ruby
> puts like this :
>
> def puts(str)
>   document.getElementById('STDOUT')['inneHTML'] += str + "\n"
> end
>
> if i do that into your HelloWorld class i get errors :

Well, does it work in Ruby? NO! So it doesn't work in RubyJS as well :)
It's a bit more advanced than converting "document" from Ruby plainly 
into "document" in Javascript. 

If you want to insert Javascript code directly into your Ruby code, use 
backticks:

  def puts(str)
    `document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
  end

In the next step, I've planned to port Google's Webtoolkit (or Python Pyjamas) 
to RubyJS.

> method_generator.rb:1040:in `method_missing': Not implemented
> (RuntimeError)
> [...]
>
> is their a way to let RubyJS knows that "document.getElementById..." is
> allready JS ???

See above :)

Regards,

  Michael