How to open up a new tab in a pop-up?

user57129 picture user57129 · Feb 23, 2014 · Viewed 9k times · Source

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.

Is this possible?

How can I do it?

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>

Here the code of the new tab:

<!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>

Answer

Johnny picture Johnny · Feb 23, 2014

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');

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"/

You can replace google URL by any URL you like.

Hope it helpful! Good luck. Johnny