# Open new window problem

**URL:** <https://www.ruby-forum.com/t/open-new-window-problem/85168>\
**Category:** Rails\
**Created:** [February 10, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/open-new-window-problem/85168 "2007-02-10T21:54:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![albert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://www.ruby-forum.com/u/albert)\
**Post date:** [February 10, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/open-new-window-problem/85168/1 "2007-02-10T21:54:58Z")

</div>

I try to open a pdf file in a new window using the following code:

\<%= link\_to document.name, :controller =\> ‘member’,  
:action =\> :show\_attachment, :id =\> document.id,  
:popup =\> [‘new window’, ‘width=800, height=700, left = 450, top = 100,  
resizable, scrollbars=yes’ ] %\>

but it opens the file in the same window.  
Any ideas why?

Many thanks,  
-Albert

---

<div class="post-metadata">

**Author:** ![albert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://www.ruby-forum.com/u/albert)\
**Post date:** [February 10, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/open-new-window-problem/85168/2 "2007-02-10T22:18:57Z")

</div>

On Feb 10, 2007, at 21:54 , albert wrote:

> I try to open a pdf file in a new window using the following code:
> 
> \<%= link\_to document.name, :controller =\> ‘member’,  
> :action =\> :show\_attachment, :id =\> document.id,  
> :popup =\> [‘new window’, ‘width=800, height=700, left = 450, top =  
> 100,  
> resizable, scrollbars=yes’ ] %\>

You’re passing the :popup options to the url options hash. You want  
to pass it as part of the html\_options hash, like this:

\<%= link\_to document.name, {:controller =\> ‘member’, :action  
=\> :show\_attachment, :id =\> document.id}, :popup =\> [‘new window’,  
‘width=800, height=700, left = 450, top = 100, resizable,  
scrollbars=yes’ ] %\>

–  
Jakob S. - [http://mentalized.net](http://mentalized.net)

---

<div class="post-metadata">

**Author:** ![albert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://www.ruby-forum.com/u/albert)\
**Post date:** [February 26, 2007, 2:02pm UTC](https://www.ruby-forum.com/t/open-new-window-problem/85168/3 "2007-02-26T14:02:41Z")

</div>

> \<%= link\_to document.name, :controller =\> ‘member’,  
> :action =\> :show\_attachment, :id =\> document.id,  
> :popup =\> [‘new window’, ‘width=800, height=700, left = 450, top = 100,  
> resizable, scrollbars=yes’ ] %\>
> 
> but it opens the file in the same window.  
> Any ideas why?

I’ve found that IE (surprise) is a bit strange when it comes to poup  
titles. If the title contains any spaces then it will open in the same  
window. I’ve observed this behaviour on IE6 so, just in case, no more  
spaces in my popup windows’ titles.

regards,

javier ramirez

## –

Estamos de estreno… si necesitas llevar el control de tus gastos  
visita [http://www.gastosgem.com](http://www.gastosgem.com) !!Es gratis!!

---

<div class="post-metadata">

**Author:** ![albert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@albert](https://www.ruby-forum.com/u/albert)\
**Post date:** [February 27, 2007, 4:01am UTC](https://www.ruby-forum.com/t/open-new-window-problem/85168/4 "2007-02-27T04:01:44Z")

</div>

I had the same problem. Check out this post - it solved the problem for  
me too.

[http://www.ruby-forum.com/topic/81000#190602](http://www.ruby-forum.com/topic/81000#190602)

Shauna
