# Redirect\_to with :anchor doesn't work in IE

**URL:** <https://www.ruby-forum.com/t/redirect-to-with-anchor-doesnt-work-in-ie/91344>\
**Category:** Rails\
**Created:** [April 7, 2007, 4:45am UTC](https://www.ruby-forum.com/t/redirect-to-with-anchor-doesnt-work-in-ie/91344 "2007-04-07T04:45:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![walls](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/91b2a8/32.png) [@walls](https://www.ruby-forum.com/u/walls)\
**Post date:** [April 7, 2007, 4:45am UTC](https://www.ruby-forum.com/t/redirect-to-with-anchor-doesnt-work-in-ie/91344/1 "2007-04-07T04:45:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![walls](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/91b2a8/32.png) [@walls](https://www.ruby-forum.com/u/walls)\
**Post date:** [February 28, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/redirect-to-with-anchor-doesnt-work-in-ie/91344/2 "2008-02-28T18:54:09Z")

</div>

> ```
> 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](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.
