跨域访问方法介绍(4)--使用 window.name 传值

Hello friends social networking, on this occasion the admin wants to share an article entitled 跨域访问方法介绍(4)--使用 window.name 传值 , we have made good, quality and useful articles for you to read and take information in. hopefully the post content is about which we write you can understand. Alright, happy reading.

浏览器窗口有 window.name 属性。这个属性的最大特点是,无论是否同源,只要在同一个窗口里,前一个网页设置了这个属性,后一个网页可以读取它。这种方法的优点是,window.name 容量很大,可以放置非常长的字符串;缺点是必须监听子窗口 window.name 属性的变化,影响网页性能。本文主要介绍使用 window.name 来实现跨域数据传递,文中所使用到的软件版本:Chrome 90.0.4430.212。

1、步骤说明

在 a.html 页面打开 c.html 页面,c.html 页面设置 window.name 属性并跳转到 b.html a.html 页面就可以获取到 c.html 页面设置的 window.name 属性的值。

2、a.html ><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>window.name 测试</title></head><body> <button onclick="openChild()">打开子页面</button></body><script type="text/javascript"> function openChild() { let childWindow = window.open(""); //监听子窗口window.name的变化 let interval = setInterval(function(){ //子窗口window.name发生变化,停止定时任务 if (childWindow.name) { clearInterval(interval); console.log(childWindow.name); childWindow.close(); } }, 2000); } </script></html>

3、b.html ><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>代理页面</title><script type="text/javascript"> alert(window.name); </script></head><body> 操作成功。该页面即将自动关闭...</body></html>

4、c.html ><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>数据</title><script type="text/javascript"> //模拟用户操作后,页面跳转 setTimeout(function() { window.name = "你好"; window.location.href = ""; }, 3000);</script></head><body> 数据...</body></html>

5、测试

把 a.html 和 b.html 放到 tomcat (端口:8080) 的 webapps\ROOT 下,c.html 放到另一个 tomcat (端口:9090) 的 webapps\ROOT 下。









原文转载:http://www.shaoqun.com/a/815660.html

跨境电商:https://www.ikjzd.com/

和男友污污的详细经过 男朋友半夜打开了我的腿:http://lady.shaoqun.com/a/247200.html

狗狗 紫黑的粗硕用力挺入撕 口述被大公狗塞的满满的:http://lady.shaoqun.com/a/246905.html

少妇口述:老公不在 我和陌生男子激情做爱3次:http://lady.shaoqun.com/m/a/78156.html

口述:妹妹和我男友爱爱时故意呻吟口述爱爱妹妹:http://lady.shaoqun.com/a/25015.html


浏览器窗口有window.name属性。这个属性的最大特点是,无论是否同源,只要在同一个窗口里,前一个网页设置了这个属性,后一个网页可以读取它。这种方法的优点是,window.name容量很大,可以放置非常长的字符串;缺点是必须监听子窗口window.name属性的变化,影响网页性能。本文主要介绍使用window.name来实现跨域数据传递,文中所使用到的软件版本:Chrome90.0.4430.
赶着花季玩四川 :http://www.30bags.com/a/409193.html
良心推荐!香港3D奇幻世界门票+开放时间+交通指南:http://www.30bags.com/a/423831.html
女人奇特的4个"性恐惧":老公好像流氓恐惧爱爱性爱:http://lady.shaoqun.com/m/a/29040.html
一晚上要了小姑娘三次 被男同事伺候的爽了一夜:http://lady.shaoqun.com/a/248129.html
口述:尴尬 丈母娘洗完澡从不穿内衣:http://lady.shaoqun.com/m/a/17380.html
赶紧预约!深圳这些地方健身、游泳、打球又将免费啦!非深户也有份!_场地:http://www.30bags.com/a/219776.html
赶快安排!贵州这里千年古银杏披"金甲"!美得不像话_习女士:http://www.30bags.com/a/220035.html
泛亚班拿:https://www.ikjzd.com/w/1262
女友原来比我大11岁 还当过二奶:http://lady.shaoqun.com/m/a/273285.html
长兴太湖龙之梦嬉水世界门票多少钱?团购票价优惠吗:http://www.30bags.com/a/443903.html
长兴太湖龙之梦嬉水世界好玩吗?简介一下怎么样啊:http://www.30bags.com/a/443904.html
男女之间不受控制的性行为列表(漫画):http://www.30bags.com/a/443905.html


That's the article: 跨域访问方法介绍(4)--使用 window.name 传值
Thank you for visiting my blog, hopefully it can be useful for all of you. Don't forget to share this article with your friends so they also know the interesting info, see you in other article posts.

You are now reading the article 跨域访问方法介绍(4)--使用 window.name 传值 with link address https://socialnetworkingupdate.blogspot.com/2021/06/4-windowname.html

More Articles

Post a Comment

Mas Bago Mas luma

Iklan In-Feed (homepage)

#Advertisement