我使用以下命令打开包含一些页面内容的新选项卡(在新进程中),
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 http://news.softpedia.com/news/Force-Google-Chrome-to-Open-Links-in-New-Processes-128962.shtml
这是有效的,新选项卡已打开,其中包含 myPage.html 内容。
假设这是 myPage(仅用于示例...)我应该如何访问它?
<!DOCTYPE html>
<html>
<body>
<h1> Heading</h1>
<p> paragraph.</p>
<button type="button">Click Me!</button>
</body>
</html>
现在让我们去棘手/高级:) 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 获得的参考
我的问题是:
如果我想更改某些内容,如何访问这个新选项卡 dom