教材上说:alert(opener.name)可以获得父窗口的名字。
cat father.html
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title></head><body> <script> window.open('file:///tmp/child.html'); </script></body><p>i am father window</p></html>
cat child.html
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <script> alert(opener.name); </script></head><body> <p>i am child window</p></body></html>
浏览器中输入 file:///tmp/father.html ,child.html也会打开,但是为何没有alert窗口打开?
子衿沉夜
相关分类