# How to use javascript in rhtml

**URL:** <https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502>\
**Category:** Rails\
**Created:** [October 25, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502 "2007-10-25T16:22:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 25, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502/1 "2007-10-25T16:22:13Z")

</div>

hello,

I needed to know a javascript function which I can use for focusing my  
cursor on the first text field of a given page.

That is as soon as I load a page, my cursor should start blinking in the  
first text field

Regards

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 25, 2007, 7:55pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502/2 "2007-10-25T19:55:48Z")

</div>

Take a look at [http://lena.franken.de/software/javascript/](http://lena.franken.de/software/javascript/)

On Oct 25, 10:22 am, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 2:39pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502/3 "2007-10-26T14:39:02Z")

</div>

Bill S. wrote:

> Take a look at [http://lena.franken.de/software/javascript/](http://lena.franken.de/software/javascript/)
> 
> On Oct 25, 10:22 am, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thank You for looking into my problem , ill definately go through the  
url.

Regards

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502/4 "2007-10-26T15:14:51Z")

</div>

What do you mean that you have to “traverse many links”? It sounded  
like you just wanted to set the focus to a text field so that the user  
can type without having to tab to the field. That’s what the script  
does.

How exactly does it fail to meet your needs?

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 26, 2007, 3:09pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-rhtml/196502/5 "2007-10-26T15:09:37Z")

</div>

Advait B. wrote:

> Bill S. wrote:
> 
> > Take a look at [http://lena.franken.de/software/javascript/](http://lena.franken.de/software/javascript/)
> > 
> > On Oct 25, 10:22 am, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> Thank You for looking into my problem , ill definately go through the  
> url.
> 
> Regards
> 
> Advait

Respecter Sir,

The tutorial is definately helpful if i have only one page and it  
captions reads

" This is useful for forms where the user should simply type in  
something witout having to navigate to the first field "

But this is not the case with mine…I traverse through many  
links…

If possible please let me know how could I carry out this process…
