Make each button, during the onclik event, trigger its own window?

0

The following code will display several "tumbnails", where each one has a button labeled "tracklist". But it happens, for example, if I click on one of the buttons and it does not close its window, all other tracklist buttons that are clicked or activated will "write" in the first opened window ...

<head>
<script type="text/javascript">
function myFunction(content) {
    var playlist = content;    
    var x = parseInt((screen.width-800)/2);
    var y = parseInt((screen.height-600)/2);
    var win = window.open( '', 'pop', 'scrollbars=1,statusbar=1,menubar=0,resizable=1,width=800,height=600' ); 
    win.document.write ('Playlist:' + playlist); 
    win.moveTo(x,y);
}
</script>
</head>

PHP

foreach($rows as $row){
   echo "<div class='tumbnail'>";
   echo "<img src='imagem.jpg'>";
   echo "<input class=\"btn_tracklist\" type=\"button\" value=\"Tracklist\" onclick=\"javascript:myFunction('" . $row['tracklist'] . "')\"> </br>";                                
   echo "</div>";
 } /*END Foreach*/
    
asked by anonymous 10.07.2014 / 22:55

1 answer

1

Modify the javascript. Instead of:

var win = window.open( '', 'pop', 'scrollbars=1,statusbar=1,menubar=0,resizable=1,width=800,height=600' ); 

use

var win = window.open( '', '_blank', 'scrollbars=1,statusbar=1,menubar=0,resizable=1,width=800,height=600' ); 

or set a different name for each window

See the window's open name parameter: link

    
10.07.2014 / 23:09