Rails 使用iframe报错:IFRAME: Refused to display document because display forbidden by X-Frame-Options
来源:互联网 发布:tor网络 编辑:程序博客网 时间:2024/06/05 17:50
第一步:在layout目录下的application.html.erb文件中添加:
例如:
<meta http-equiv="X-Frame-Options" content="GOFORIT">例如:
<!DOCTYPE html><html><head> <title>电子病历系统</title> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <meta http-equiv="X-Frame-Options" content="GOFORIT"> <%= csrf_meta_tags %></head><body><%= yield %></body></html>
第二步:在controllers目录下的application_controller.rb添加:
protect_from_forgery with: :exception before_filter :add_xframe def add_xframe headers['X-Frame-Options'] = 'GOFORIT' end
例如:
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_filter :add_xframe def add_xframe headers['X-Frame-Options'] = 'GOFORIT' endend
这样浏览器会报如下警告信息:
'Invalid 'X-Frame-Options' header encountered when loading....GOFORIT' is not a recognized directive. The header will be ignored.
即把‘GOFORIT’换成‘ALLOWALL’就ok了
- Rails 使用iframe报错:IFRAME: Refused to display document because display forbidden by X-Frame-Options
- 浏览器IFrame出Refused to display 'URL' in a frame because it set 'X-Frame-Options' to 'DENY' 的错
- 浏览器IFrame出Refused to display 'URL' in a frame because it set 'X-Frame-Options' to 'DENY' 的错
- 使用SpringSecurity4引发的问题:Refused to display 'http://localhost:8080/xx in a frame because it set 'X-Fr
- .NET MVC Iframe 'X-Frame-Options' to 'SAMEORIGIN' 解决办法
- HTTP X-Frame-Options 防止iframe内框架调用
- BUG: in a frame because it set 'X-Frame-Options' to 'deny'
- in a frame because it set 'X-Frame-Options' to 'DENY'.
- Spring Boot 出现 in a frame because it set 'X-Frame-Options' to 'DENY'
- how to display a loading gif when using jquery ui dialog iframe
- the travel of solving iframe navigate to display page of certain part of parent html page
- iframe / frame
- iframe frame
- iframe frame
- frameset ,frame,iframe 的使用
- Using UIWebView to display select document types
- Xlib: connection to "0.0" refused by server Xlib: No protocol specified Error:Can't open display:0.0
- apache报错: Directory index forbidden by Options directive: /var/www/html
- C#书写规范
- comboBox常用的基本用法
- 简单工厂模式
- 机器学习资源积累
- 单元测试 集成测试 系统测试 验收测试
- Rails 使用iframe报错:IFRAME: Refused to display document because display forbidden by X-Frame-Options
- IOS开发之隐藏软键盘
- Android应用签名
- 社会化视频推荐系统应用
- 数据通信系统的基本模型
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- 如何使用Nikto漏洞扫描工具检测网站安全
- InputBox函数
- C++的4种类型转换关键字及其特点