iframe
能够帮助咱们在一个网页中嵌套另外一个网页(好比:jquery项目中嵌套react页面),它的用法咱们以实际例子说明:html
在本地写了一个index.html,使用http-server启动服务:react
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <iframe src="http://47.111.228.207:8080/#/pageA" frameborder="0" width="100%" height="1000" scrolling="no"></iframe> </body> </html>
在index.html中咱们嵌套了一个iframe,指向我以前部署在服务器上的react页面(http://47.111.228.207:8080/#/pageA)jquery
如今浏览器打开http://localhost:8080/apache
能够看到已经成功的将react页面嵌套进去了。浏览器
可是,问题也出来了,http://47.111.228.207:8080/#/pageA这个页面能够被任意的劫持使用,若是被钓鱼网站使用,植入一些小广告或者其余的,那么这些风险都会影响咱们网站的性能以及安全性。tomcat
那么,如何去规避这些风险呢?安全
常见方式是在apache 或者 tomcat服务器上配置X-Frame-Options响应头服务器
X-Frame-Options
是为了减小点击劫持(Clickjacking)而引入的一个响应头,这个响应头支持三种配置:性能
咱们来试试如何在tomcat配置响应头:网站
参考:
https://www.pianshen.com/arti...
https://www.cnblogs.com/wdnnc...
https://developer.mozilla.org...