如何在弹出窗口中打开一个新标签?

2022-01-20 00:00:00 popup tabs javascript html radio

我对编程了解不多,但不知何故我设法使弹出窗口工作.但是,我需要在新窗口(弹出窗口)中,弹出窗口上的一个按钮将打开一个新选项卡.但我不需要在主浏览器中打开新标签,我希望它在同一个弹出窗口中打开.

I don't know too much about programming but somehow I managed to make a pop-up window work. However, I need that from inside the new window (the pop-up one) a button on the pop-up will open a new tab. But I don't need the new tab open in the main browser, I want it open in the same pop-up.

这可能吗?

我该怎么做?

我同时显示了弹出代码和重定向代码,即目前将人们发送到我的网络浏览器中的另一个选项卡,但我需要在已经打开的同一个弹出窗口中执行此操作.这是弹出窗口中的代码:

I show both the pop-up code and the redirection code that is, at present, sending people to another tab in my web browser, but I need to do it in the same pop-up window that is already open. Here is the code in the pop-up:

<!DOCTYPE html>
<html>
<body>

<p>Click aquí para escuchar Radio Lineage.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
window.open("http://localhost:8000/player/index.html");
}
</script>

</body>
</html>

这里是新标签的代码:

<!DOCTYPE html>
<html>
<body>
.
.
<script type="text/javascript" src="http://hosted.musesradioplayer.com/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'localhost:8000/stream',
'lang':'es',
'codec':'mp3',
'volume':65,
'autoplay':true,
'buffering':5,
'title':'Radio LineageChile',
'welcome':'Bienvenido a...',
'bgcolor':'#FFFFFF',
'skin':'radiovoz',
'width':220,
'height':69
});
</script>
.
.
</body>
</html>

推荐答案

要在同一个弹出窗口中打开新 URL,我从您的代码中编辑如下:

To open new URL in the same popup window, from your code, I edited to below:

var win = window.open("http://localhost:8000/player/index.html", 'newwin', 'height=200px,width=200px');

运行此行后,将显示新的弹出窗口,高度=200px,宽度=200px.要在同一个弹出窗口 (win) 中打开新 URL,请使用此行

after run this line, new popup window will be showed with height=200px, width=200px. To open new URL in the same popup windown (win), use this line

win.location = "http://www.google.com"/

win.location = "http://www.google.com"/

您可以用任何您喜欢的网址替换谷歌网址.

You can replace google URL by any URL you like.

希望对您有所帮助!祝你好运.强尼

Hope it helpful! Good luck. Johnny

相关文章