Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open response on new window

Tags:

django

In Django, how can I get the response to be opened in a new window from the view?

if i do this, this will open the mynewpage.html in the original window

return HttpResponse('mynewpage')

I want to open mynewpage.html in a new window , separate from the originial.

like image 496
Youssef Avatar asked Apr 05 '12 08:04

Youssef


1 Answers

Your server has no concept of windows - it just sends back files to the browser. You need to do this via javascript:

window.open('url to open','window name','attribute1,attribute2')

So you can either create a custom view and template whose job is to open a new window with a specified link, then return the main window to the page it was previously at, or simply open the url you want from the original window without contacting the server

like image 185
Timmy O'Mahony Avatar answered Nov 17 '22 17:11

Timmy O'Mahony