Render :js => "window.close();" wont work

when i try to do the following in a action
render :js => “window.close();” wont work

it still response in the browser,but the window wont close.
i dont know why.thx!

*Ըϲͬ!

ʯҾ
ϢѧԺ ϵӦ÷
Dalian NEUSOFT Institute of Information
й-԰·8
ʱࣺ116023
*Mail:[email protected] [email protected]
Phone:15242613529

On Mar 27, 2012, at 10:17 AM, yan shi wrote:

when i try to do the following in a action
render :js => “window.close();” wont work

it still response in the browser,but the window wont close.
i dont know why.thx!

You can only close a window in JavaScript if you also opened it in
JavaScript. So this will work on a popup window you opened, but it won’t
work on a window the user opened. Which is yours? Also, some browsers
further kink this so that the window.close() event will only work if it
was fired from a user click, not a JavaScript program running on its own
without user interaction.

Walter

thx very much. so is there any ways to accomplish that?

2012327 11:02Walter Lee D. [email protected]д

JavaScript. So this will work on a popup window you opened, but it won’t

ʯҾ
Groups “Ruby on Rails: Talk” group.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


*Ըϲͬ!

ʯҾ
ϢѧԺ ϵӦ÷
Dalian NEUSOFT Institute of Information
й-԰·8
ʱࣺ116023
*Mail:[email protected] [email protected]
Phone:15242613529

muchas gracias

2012327 11:10Walter Lee D. [email protected]д

Walter

i dont know why.thx!


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


*Ըϲͬ!

ʯҾ
ϢѧԺ ϵӦ÷
Dalian NEUSOFT Institute of Information
й-԰·8
ʱࣺ116023
*Mail:[email protected] [email protected]
Phone:15242613529

On Mar 27, 2012, at 11:05 AM, yan shi wrote:

thx very much. so is there any ways to accomplish that?

If you’re asking if the page can close the main (or any user-opened)
window, the answer is no, and for good reason. The page can close itself
if the window was opened programmatically, but it sounds as if you are
not talking about doing that, so the answer is no.

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs