gpt4 book ai didi

javascript:从原始页面中的 window.open 页面打开 URL

转载 作者:行者123 更新时间:2023-11-30 18:09:46 25 4
gpt4 key购买 nike

我正在从“主”网页打开一个较小的网络浏览器窗口。 “子”窗口包含如下链接...

<a onclick="javascript:window.open('http://someplace.com/','_blank');">Someplace</a>

但我不想使用目标“_blank”,而是使用原始“主”网页窗口的名称,并在该窗口中打开链接。有什么建议如何做到这一点?

最佳答案

按照这个例子来帮助你解决你的问题:

<!DOCTYPE html>
<html>
<head>
<script>
function openWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.focus();
myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>
</head>
<body>

<input type="button" value="Open 'myWindow'" onclick="openWin()" />

</body>
</html>

关于javascript:从原始页面中的 window.open 页面打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14883765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com