# Determining width of viewing window

**URL:** <https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842>\
**Category:** Rails\
**Created:** [April 12, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842 "2007-04-12T19:54:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 12, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842/1 "2007-04-12T19:54:52Z")

</div>

Does Rails provide a means for determining the width of the viewing  
area? What I’d like to do is to be able to say something like,  
‘style=“width: 100%-140px”’. Thanks.

```
   ... doug
```

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 12, 2007, 8:16pm UTC](https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842/2 "2007-04-12T20:16:54Z")

</div>

that’s a server side issue, so it’s not as much as Rails issue as a  
Javascript issue. And as far as I know, Rails doesn’t have any helpers  
for  
that kind of function. Try looking around for the terms javascript and  
window.width. that should get you started…

On 4/12/07, doug [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Mike W.  
Web D.  
UW-Eau Claire

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 12, 2007, 8:44pm UTC](https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842/3 "2007-04-12T20:44:57Z")

</div>

On 12 Apr 2007, at 19:54, doug wrote:

> Does Rails provide a means for determining the width of the viewing  
> area? What I’d like to do is to be able to say something like,  
> ‘style=“width: 100%-140px”’. Thanks.

The width of a viewing area is a clientside thing, Rails is a  
serverside framework. You need to look into Prototype (a JavaScript  
framework), which has functions to handle this kind of thing. I can  
recommend the “Prototype & Scriptaculous in Action” book from Manning  
as well as the prototype API on Position: [Prototype API Documentation | Home (Deprecated URL)](http://prototypejs.org/api/)  
position

A google search should also bring up a couple of things.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 12, 2007, 11:40pm UTC](https://www.ruby-forum.com/t/determining-width-of-viewing-window/91842/4 "2007-04-12T23:40:18Z")

</div>

Thanks to all. With the help I obtained, I got it working. The point  
about the dimensions of the viewing area being a client-side thing is  
well taken. Thanks again.

```
   ... doug
```
