当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
目标检测-中篇
KingbaseES数据库启动失败,报“内存段超过可用内存”
How to read the resources files in the directory path?
Deep Learning (3) Classification Theory Part
A Preliminary Study of RSS Subscription to WeChat Official Account-feed43
Functions, recursion and simple dom operations
【源码】使用深度学习训练一个游戏
FFmpeg —— 通过修改yuv,将视频转为黑白并输出(附源码)
【 observe 】 super fusion: the first mention of "calculate net nine order" evaluation model, build open prosperity of power network
sql语句查询String类型字段小于10的怎么查
如何读取 resources 目录下的文件路径?
DIY电工维修如何拆卸和安装开关面板插座
从图文展示到以云为核,第五代验证码独有的策略情报能力
STM8S-----option byte
数据安全峰会2022 | 美创DSM获颁“数据安全产品能力验证计划”评测证书
函数,递归以及dom简单操作
自定义通用分页标签02
张量篇-应用案例
Brush esp8266-01 s firmware steps
[Study Notes Dish Dog Learning C] Dynamic Memory Management