Hi all:
I can''t make redirect_to to unlock the current iframe using {:TARGET
=>
"_top"}. It always stays in the current frame. I checked the
redirect_to code, it seems the method does not use "target". here is
the
source code of redirect_to from ActionController::Base
def redirect_to(options = {}, *parameters_for_method_reference) #:doc:
753: case options
754: when %r{^\w+://.*}
755: raise DoubleRenderError if performed?
756: logger.info("Redirected to #{options}") unless
logger.nil?
757: response.redirect(options)
758: response.redirected_to = options
759: @performed_redirect = true
760:
761: when String
762: redirect_to(request.protocol + request.host_with_port
+ options)
763:
764: when :back
765: redirect_to(request.env["HTTP_REFERER"])
766:
767: else
768: if parameters_for_method_reference.empty?
769: redirect_to(url_for(options))
770: response.redirected_to = options
771: else
772: redirect_to(url_for(options,
*parameters_for_method_reference))
773: response.redirected_to,
response.redirected_to_method_params = options,
parameters_for_method_reference
774: end
775: end
776: end
------------------------------------------------------------------------
'' when %r{^\w+://.*} '' does not use
''parameters_for_method_reference''.
Bug ?
I also tried to use response directly as follows:
response.redirect(params[:url]+'' target="_top"'')
response.redirected_to = params[:url]+''
target="_top"''
but it didn''t work. Is this a know bug ?
thanks in advance for your reply.
regards
Susanta
Here is my sample code:
controller: BlogController
--------------------code-----------------------------------
class BlogController < ApplicationController
def index
end
def otherFrame
render(:layout => false)
end
def show
redirect_to(params[:url], {:TARGET => "_top"})
end
end
</BlogController.rb >
layout: blog
blog
<html>
<body>
<iframe src="otherFrame" marginheight=2 marginwidth=2
allowTransparency="true" width=700 height=110>
</iframe>
<%= @content_for_layout %>
</body>
</html>
-------------------------------
views: index.rhtml
--------------------code-----------------------------------
<p>I am in a different frame</p>
-----------------------------
views: otherFrame.rhtml
--------------------code-----------------------------------
<html>
<body>
<p>Locked in a frame?</p>
<%= link_to ''click me'', :action =>
''show'', :url
=>"http://www.rubyonrails.org/" %>
</body>
</html>
------------------------------
--
Posted via http://www.ruby-forum.com/.