Django解決frame拒絕問題的方法
template/home.html
<!DOCTYPE html><html lang='en'><meta http-equiv='Content-Type' content='text/html' charset='UTF-8'><head> <title>自動化測試平臺</title></head><frameset rows='*' cols='265,*' framespacing='0' frameborder='yes' border='0'> <frame src='http://www.aoyou183.cn/left' name='leftFrame' scrolling='auto' noresize> <frame src='http://www.aoyou183.cn/welcome' name='mainFrame' scrolling='NO' noresize></frameset><noframes> <body> <h1>hello</h1> </body></noframes></html>二、視圖文件
AutoTestPlat/views.py
def home(request): return render(request, ’home.html’)def left(request): return render(request, ’left.html’)def welcome(request): return render(request, ’welcome.html’)三、urls映射文件
urlpatterns = [ path(’admin/’, admin.site.urls), path(’’, views.login), path(’login/’, views.login), path(’home/’, views.home), path(’left/’, views.left), path(’welcome/’, views.welcome),]
命令行執行python manage.py runserver后,Chrome瀏覽器打開http://127.0.0.1:8000/home/,顯示如下圖。打開F12,報以下錯誤。
在setting.py中設置:
# 解決frame跨域問題X_FRAME_OPTIONS = ’ALLOWALL url’
到此這篇關于Django解決frame拒絕問題的方法的文章就介紹到這了,更多相關Django frame拒絕內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章: