当前位置:网站首页>Learn iframes and use them to solve cross-domain problems
Learn iframes and use them to solve cross-domain problems
2022-08-04 03:35:00 【M78_Domestic 007】
Learn about iframes
The official definition is: iframe is HTML tag, which acts as a document in a document, or floatsframe (FRAME).The iframe element creates an inline frame (ie, an inline frame) that contains another document.
Simply understood as: iframe is an inline frame that can embed another document in the current HTML page.
iframe attributes
Only common attributes are introduced here
name: Specifies the name of the
width: Specifies the width of the
height: Specifies the height of the
src: Specifies the URL of the document displayed in the
frameborder: HTML5 not supported.Specifies whether to display a border around the
scrolling: HTML5 not supported.Specifies whether to display scrollbars in the
align: HTML5 not supported.HTML 4.01 is obsolete.Specifies how to align the
Simple demo:
Demonstrate the use of iframe
We set an inline frame named ifr with a width of 600 and a height of 400, showing the border, hiding the slider, and showing the document as site b (you can also choose a local html document).We can write a text description in the iframe tag, because some low-version browsers do not support this tag, and when the document cannot be displayed, the text we wrote will be displayed on the page.
Open the browser to see the effect:

Get the content inside the iframe
Demonstrate the use of iframe
Resolving cross-domain issues
1. document.domain+iframe
This method can only be used for cross-domain requests between different subdomains under the same main domain, such as between a.com and 1.a.com, and between 1.a.com and 2.a.com.
Just point the document.domian of both pages to the main domain, such as document.domain="a.com".
The parent page embeds the child page through iframe, obtains the window of the child page through iframe.contentWindow, and then operates the child page, and the child page accesses the window of the parent page through parent.window and parent.
Write an example:
//Parent page http://a.com/a.html//Subpage http://1.a.com/b.htmldocument.domain="a.com"var name2=2//Get the properties of the parent pagevar name11=parent.window.name12. window.name+iframe
The implementation is to pass data based on window.name.name is a property of the global window object in the browser environment.
When a new page is loaded in an iframe, the value of the name property remains the same.
边栏推荐
- 深度学习——以CNN服装图像分类为例,探讨怎样评价神经网络模型
- FFmpeg —— 通过修改yuv,将视频转为黑白并输出(附源码)
- JVM的内存模型简介
- 什么是数字孪生智慧城市应用场景
- Innovation and Integration | Huaqiu Empowerment Helps OpenHarmony Ecological Hardware Development and Landing
- mq应用场景介绍
- 2千兆光+6千兆电导轨式网管型工业级以太网交换机支持X-Ring冗余环网一键环网交换机
- 类如何只能静态分配和只能动态分配
- Polygon zkEVM网络节点
- 【MD5】采用MD5+盐的加密方式完成注册用户和登录账号
猜你喜欢
随机推荐
Why use Selenium for automated testing
帮助企业实现数字化转型成功的八项指导原则
kingbaseES V8R2/R3 表在指定表空间,为何显示为默认表空间?
出现504怎么办?由于服务器更新导致的博客报504错误[详细记录]
案例 | 重庆银行流动数据安全挑战及应对实践
Introduction to the memory model of the JVM
如何读取 resources 目录下的文件路径?
机器学习模型的“可解释性”
docker+bridge+redis master-slave+sentry mode
基于Qt的目录统计QDirStat
XSS相关知识点
Y86. Chapter iv Prometheus giant monitoring system and the actual combat, Prometheus storage (17)
db2中kettle报错 Field [XXX] is required and couldn‘t be found 解决方法
函数,递归以及dom简单操作
SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropri
Gigabit 2 X light 8 electricity management industrial Ethernet switches WEB management - a key Ring Ring net switch
元宇宙“吹鼓手”Unity:疯狂扩局,悬念犹存
DIY电工维修如何拆卸和安装开关面板插座
千兆2光8电管理型工业以太网交换机WEB管理X-Ring一键环网交换机
if,case,for,while









