码迷,mamicode.com
首页 > Windows程序 > 详细

14.4 window.name

时间:2019-02-01 19:45:35      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:引用   style   fir   exp   func   name   get   listen   lse   

a.html

 <!--
 a和b是同域的:http://localhost:3000
 c是独立的:http://localhost:4000
 a获取c的数据

 a先引用c c把值放到window.name上,把a引用的地址改到b
 -->
<iframe src="http://localhost:4000/c.html" frameborder="0" onload="load()" id="iframe"></iframe>
<script>
    let first = true
    function load() {
      if (first) {
        let iframe = document.getElementById(iframe)
        iframe.src = http://localhost:3000/b.html
        first = false
      } else {
        console.log(iframe.contentWindow.name)
      }
    }
</script>

b.html  空页面

c.html

<script>
    window.name = 我不爱你
</script>

 

服务端

a.js

let express = require(express)
let app  = express()
app.use(express.static(__dirname))
app.listen(3000)

b.js

let express = require(express)
let app  = express()
app.use(express.static(__dirname))
app.listen(4000)

 

14.4 window.name

标签:引用   style   fir   exp   func   name   get   listen   lse   

原文地址:https://www.cnblogs.com/zouxinping/p/10346737.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!