# DOM values in ERB Variable?

**URL:** <https://www.ruby-forum.com/t/dom-values-in-erb-variable/62039>\
**Category:** Rails\
**Created:** [May 30, 2006, 11:31pm UTC](https://www.ruby-forum.com/t/dom-values-in-erb-variable/62039 "2006-05-30T23:31:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [May 30, 2006, 11:31pm UTC](https://www.ruby-forum.com/t/dom-values-in-erb-variable/62039/1 "2006-05-30T23:31:10Z")

</div>

I am trying to post the current brower window sizes into the user’s  
session file with a form\_remote\_tag call as follows:

\<%= form\_remote\_tag :url =\> url\_for(:controller =\> “welcome”, :action  
=\> “login”, :iheight =\> “1”, :iwidth =\> “2”) %\>

But how do I get the DOM data for window.innerHeight and  
window.innerWidth into an ruby ERB variable such that I can put into  
the helper, and POST them in to the controller? Or is there a better  
way? I feel like I am missing some really simple here.

Anyone come up against this, and / or know the answer? If so, please  
help.

–ejw

Eric W.  
Email: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [May 31, 2006, 1:47am UTC](https://www.ruby-forum.com/t/dom-values-in-erb-variable/62039/2 "2006-05-31T01:47:12Z")

</div>

Eric W. wrote:

> I am trying to post the current brower window sizes into the user’s  
> session file with a form\_remote\_tag call as follows:
> 
> \<%= form\_remote\_tag :url =\> url\_for(:controller =\> “welcome”, :action  
> =\> “login”, :iheight =\> “1”, :iwidth =\> “2”) %\>
> 
> But how do I get the DOM data for window.innerHeight and  
> window.innerWidth into an ruby ERB variable such that I can put into  
> the helper, and POST them in to the controller? Or is there a better  
> way? I feel like I am missing some really simple here.
> 
> Anyone come up against this, and / or know the answer? If so, please  
> help.
> 
> –ejw
> 
> Eric W.  
> Email: removed\_email\_address@domain.invalid

Since Rails doesn’t actually run on the client, rails only has the info  
that was included in the request to go on, and screen size is not in the  
request that browser make to your app.

So…

You need to render the page first and then use javascript to trigger an  
AJAX call that posts some variables back to the server. Something like

Ajax.Request(’/users/screen\_size?width=’+screenWidth()+‘height=’+screenHeight());
