Question

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>

No correct solution

OTHER TIPS

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

Here the code, just a very small code, that will open the new page as a popup window.Code is working properly.

 <!DOCTYPE html>
 <html>
<body>

 <p>Click the button to open an about:blank page in a new browser window that is 1200px wide and 600px tall.</p>

 <button onclick="openWin()">Open Window</button>

 <script>
 function openWin()
{
 var myWindow = window.open("","","width=1200,height=600");
}
</script>

  </body>
  </html>
<script type="text/javascript">
        win = null;
        function openPopup(){
            win = window.open("http://www.google.com", 'newwin', 'height=200px,width=200px');
        }
        function openOtherUrl(){
            win.location = 'http://www.yahoo.com';
        }
    </script>

you can use this code, I change URl successfully with it. Hope it will be helpful for you!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top