5👍
This question is a little old, but I just went through this and I think I can help anyone looking for an answer in the future.
I ran into this problem because the website I was building had a built-in tracking system that tracked the URLs of outbound links for self-hosted ads. If I don’t redirect, there is no way (without changing the way it was implemented) to track the click, since I’m not using an API or anything.
The easy fix was to do what you did, sending back an HttpResponse()
whose content is the meta tag
<meta http-equiv="refresh" content="0;url=mailto:youremail@test.com" />
This causes the page to refresh on load, which triggers the mailto:
action.
Now we’re left with an open window, but we can’t close the window using Javascript’s window.close()
method. I do believe that this solution should work, however. Call that Javascript function after the refresh has been successful.
Unfortunately, I haven’t tested this, but these two methods should accomplish a mailto:
redirect that does not leave a blank window/tab behind.
Hope this helps!
1👍
Don’t use HttpResponseRedirect. Just make the mailto: line a link. <a href="mailto:email1...">Email selected members</a>
- [Django]-How to use different database within same app in django?
- [Django]-ImportError: No module named models?
- [Django]-Changing django-storages backend from from s3 to cloudfiles and dealing with old files
0👍
I don’t think it is possible. RFC 2616 says re 302 redirect:
The temporary URI SHOULD be given by
the Location field in the response.
Unless the request method was HEAD,
the entity of the response SHOULD
contain a short hypertext note with a
hyperlink to the new URI(s)
So the blank page that I see is the (very) short hypertext note. The browser gets the redirect instruction, pops up a temporary page with the redirect message, then retrieves the redirected URL. But with a mailto: URL the temporary page obviously remains.