redirect_to with :anchor doesn't work in IE

Hi All,

I'm redirecting to an action with an :anchor like:

    redirect_to :action => "index", :anchor => @photo.id.to_s

index.rhtml is a page has many photos thumbnails and each photo would
have the id as the "id" for <a href> link. I suppose this would
directly let the browser jump to that photo with the specific id.

Actually, it works fine in FireFox with the url in address bar
redirected to http://localhost/photo#157

However, in Internet Explorer (both version 6 and version 7), it
failed to work. The address bar in IE still displays http://localhost/photo.
It seems the :anchor doesn't append to the url for IE browser.

Any advise? And thanks very much in advance :slight_smile:

Regards,

Norman

    redirect_to :action => "index", :anchor => "error"

      > .., in Internet Explorer (both version 6 and version 7), it
failed to work.
      > The address bar in IE still displays http://localhost/photo.

Is there a "clean" solution to this problem?

For the record, I use this hack/workaround :

   In the controller :
       flash[:scroll_to_for_ie] = 'flash_error'
       redirect_to ..., :anchor => 'flash_error'

   In the layout
         ...
         <% if flash[:scroll_to_for_ie] %>
            <script type="text/javascript" charset="utf-8">
               document.observe("dom:loaded", function(){
                  if(Prototype.Browser.IE){$('<%=
flash[:scroll_to_for_ie] %>').scrollTo();}
                } );
            </script>
         <% end -%>
      </head>

Alain Ravet