On Thu, 2007-03-15 at 07:51 +0000, char wrote:
> I'd like to be able to do something like the following in views.py:
> 
> return render_to_response( 'my_app/my_page.html/#my_anchor',
> context_instance=RequestContext( request ) )
> 
> 
> The above obviously doesn't work because it's just a filepath, not a
> url. But basically, when I return from a view to a particular web page
> I'd like to specify an anchor tag to return to. Is there a way to do
> this? I'd also like to do this with HttpResponseRedirect as well.

Since anchors are processed on the clientside in HTTP, this is actually
fairly straightforward (you have to use redirects):

(1) You send back a 304 response (HttpResponseRedirect) to the URL
including the anchor portion.

(2) The browser will send you a request for that page (without the
anchor fragment).

(3) You send back the full page in your reply.

(4) The browser will display the page and reposition the display so that
the anchor is at the top of the screen (subject to things like page
length, etc).

Since you aren't going to see the anchor portion in the request, you
don't have to worry about processing it at all. All you (the
server-side) are responsible for doing is to send back the full page
requested and let the browser worry about the anchor.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to