当前位置:网站首页>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.name1
2. 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.
边栏推荐
- 移动端响应式适配的方法
- keytool命令
- 什么是数字孪生智慧城市应用场景
- 移动支付线上线下支付场景
- Returns the maximum number of palindromes in a string
- 自定义通用分页标签02
- 安装postgis时报找不到“POSTGIS_VERSION”这个函数
- 怎么把elastic中的异常登录ip和日志自动导出或抓取到数据库中?
- Pine Script | How to display and typeset a plot switch?
- 2 Gigabit Optical + 6 Gigabit Electric Rail Type Managed Industrial Ethernet Switch Supports X-Ring Redundant Ring One-key Ring Switch
猜你喜欢
Gigabit 2 X light 8 electricity management industrial Ethernet switches WEB management - a key Ring Ring net switch
Basic form validation process
LeetCode每日一题(2285. Maximum Total Importance of Roads)
[Medical Insurance Science] To maintain the safety of medical insurance funds, we can do this
6-port full Gigabit Layer 2 network managed industrial Ethernet switch Gigabit 2 optical 4 electrical fiber self-healing ERPS ring network switch
How to drop all tables under database in MySQL
Detailed analysis of scaffolding content
如果禁用了安全启动,GNOME 就会发出警告
SQL注入中 #、 --+、 --%20、 %23是什么意思?
企业直播风起:目睹聚焦产品,微赞拥抱生态
随机推荐
This Thursday evening at 19:00, the fourth live broadcast of knowledge empowerment丨The realization of equipment control of OpenHarmony smart home project
创新互融|华秋赋能助力OpenHarmony生态硬件开发落地
FFmpeg —— 通过修改yuv,将视频转为黑白并输出(附源码)
缓存穿透、缓存击穿、缓存雪崩以及解决方案
Deep Learning (3) Classification Theory Part
TOML configuration file format, YAML's top contender
Mockito unit testing
自定义通用分页标签02
复现20字符短域名绕过
STM8S项目创建(STVD创建)---使用 COSMIC 创建 C 语言项目
基于 SSE 实现服务端消息主动推送解决方案
Postgresql源码(66)insert on conflict语法介绍与内核执行流程解析
LeetCode每日一题(2285. Maximum Total Importance of Roads)
docker+bridge+redis master-slave+sentry mode
[Study Notes Dish Dog Learning C] Dynamic Memory Management
Power button (LeetCode) 215. The first K largest elements in the array (2022.08.03)
How many ways do you know about communication between multiple threads?
keytool命令
十一种概率分布
sql注入一般流程(附例题)