描述
A網(wǎng)頁為一個(gè)專門設(shè)計(jì)的登錄頁面login.html,通過iframe嵌套在B頁面中index.html,登錄后會(huì)進(jìn)入后臺(tái)C頁面consule.html.問題來了,登錄成功后,通過Django-url跳轉(zhuǎn),頁面一直在iframe里面,沒有跳出嵌入的框架中。
解決方法
通過HttpResponse來返回一段js腳本,直接讓你丫的跳,代碼如下
def login(request): login_form = loginForm() if request.method == 'POST': login_form = loginForm(request.POST) if login_form.is_valid(): username = login_form.data['username'] #通過js來跳轉(zhuǎn)頁面,取巧 jump_to_console = '''''' response = HttpResponse(jump_to_consule) response.set_cookie("username",username") return response else: pass return render_to_response('login_iframe.html', {'form': login_form},)