<分区>
我使用以下命令打开带有一些页面内容的新标签页(在新进程中),
var p = document.getElementById("myElement");
var a = document.createElement('a');
a.setAttribute('href',".../mypage.html");
a.setAttribute('rel',"noreferrer");
a.setAttribute('target',"_blank");
p.appendChild(a);
a.click();
http://news.softpedia.com/news/Force-Google-Chrome-to-Open-Links-in-New-Processes-128962.shtml
这是有效的,新标签打开时包含 myPage.html 内容。
假设这是我的页面(仅供示例...)我应该如何访问它?
<!DOCTYPE html>
<html>
<body>
<h1> Heading</h1>
<p> paragraph.</p>
<button type="button">Click Me!</button>
</body>
</html>
Now Let's go to the tricky/advanced :) part...
当您使用 window.open
(我不能使用)时,这非常简单,因为您可以使用各种技术。
1. using window object
2. post message
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
3. cookies
4. localStorage
但在这里我打开这个新页面时没有使用 window.open 获得的引用
我的问题是:
How can I access to this new tab dom if I want to change something