当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
Architecture of the actual combat camp module three operations
2 Gigabit Optical + 6 Gigabit Electric Rail Type Managed Industrial Ethernet Switch Supports X-Ring Redundant Ring One-key Ring Switch
帮助企业实现数字化转型成功的八项指导原则
sqoop ETL tool
"Introduction to nlp + actual combat: Chapter 8: Using Pytorch to realize handwritten digit recognition"
db2中kettle报错 Field [XXX] is required and couldn‘t be found 解决方法
目标检测-中篇
逻辑漏洞----其他类型
Implementing a server-side message active push solution based on SSE
【源码】使用深度学习训练一个游戏
全网没有之一的JMeter 接口测试流程详解
数组相关 内容 解析
tkmapper的crud示例:
Pine Script | How to display and typeset a plot switch?
一文看懂推荐系统:召回04:离散特征处理,one-hot编码和embedding特征嵌入
怎样提高网络数据安全性
机器学习之视频学习【更新】
用户与用户互发红包/支付宝C2C/B2C现金红包php源码示例/H5方式/兼容苹果/安卓
The keytool command
元宇宙“吹鼓手”Unity:疯狂扩局,悬念犹存









