# Js\_eval vs execScript

**URL:** <https://www.ruby-forum.com/t/js-eval-vs-execscript/166944>\
**Category:** Ruby\
**Created:** [May 1, 2009, 8:57am UTC](https://www.ruby-forum.com/t/js-eval-vs-execscript/166944 "2009-05-01T08:57:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [May 1, 2009, 8:57am UTC](https://www.ruby-forum.com/t/js-eval-vs-execscript/166944/1 "2009-05-01T08:57:36Z")

</div>

He guys,

I have a problem making any of the following running:

```
Browser.document.js_eval("alert('boo');");
Browser.document.js_eval("document.getElementById('ctl00_cntMainContent_Txt_Message_RTB').value='testing'");

```

I made the following script to write some string in tinymce editor

if $BrowserName == “FF” then  
Browser.document.js\_eval(“tinyMCE.execInstanceCommand(‘ctl00\_cntMainContent\_Txt\_Message\_RTB’,  
‘mceSetContent’, false, ‘Test Mail’)”);  
else  
Browser.document.parentWindow.execScript(“tinyMCE.execInstanceCommand(‘ctl00\_cntMainContent\_Txt\_Message\_RTB’,  
‘mceSetContent’, false, ‘Test Mail’)”)  
end

The one for IE working great, but js\_eval is not working, even if I use  
simpler JS like alert(‘Hi’);

Any advice please?

Really appreciate your help.  
Thanks!

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [May 8, 2009, 1:36pm UTC](https://www.ruby-forum.com/t/js-eval-vs-execscript/166944/2 "2009-05-08T13:36:28Z")

</div>

Hey guys,

Please any idea, how to make js\_eval works?  
I need to show a confirm dialog as a start.  
Then I need to execute JS in FF, any replacement for js\_eval

Many thanks.
