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 id="frame" rows="*" cols="265,*" framespacing="0" frameborder="yes" border="0">
<frame src="../left" name="leftFrame" scrolling="auto" noresize>
<frame src="../welcome" name="mainFrame" scrolling="NO" noresize>
</frameset>
<noframes>
<body>
<h2>hello</h2>
</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')
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拒绝如何解决问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。