Redirect_to with :anchor doesn't work in IE


#1

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 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


#2
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] %>

<% end -%>

Alain R.