Forum: Ruby on Rails redirect_to with :anchor doesn't work in IE

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ab7935058b7d7061e4dbe0957d2170a9?d=identicon&s=25 Yi Yang (walls)
on 2007-04-07 04:45
(Received via mailing list)
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 :)


Regards,


Norman
Ba3a00606eb530dcab2c4a6a59bf366d?d=identicon&s=25 Alain Ravet (Guest)
on 2008-02-28 18:54
(Received via mailing list)
>     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
This topic is locked and can not be replied to.