This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                6年前关闭。
            
        

下面的代码在同一页面中打开pagina.php,但是我想在另一个窗口中打开它。

(在com的查询中显示“ Como abrir pagina en otra ventana”吗?在quiero es quiero es abrirla en otra ventana中,El siguiente codigo me abre la pagina.php dentro de la misma pagina

<html>
<head>
<script type="text/javascript" src="jquery-1.10.0.min.js"></script>
<script language="JavaScript" type="text/JavaScript">
   $(document).ready(function(){
        $("#select1").change(function(event){
            var id = $("#select1").find(':selected').val();
           $(location).attr('href','pagina.php?id='+id);
        });
    });
</script>
</head>
 <body>
      <select name="select1" id="selec#1">
        <option value='1'>opcion una </option>
     </select>
 </body>
</html>

最佳答案

代替(en lugar de):

$(location).attr('href','pagina.php?id='+id);


使用(utilizar):

window.open('pagina.php?id='+id,'_blank');








您的代码已更正(elcódigocorregido):

<html>
<head>
<script type="text/javascript" src="jquery-1.10.0.min.js"></script>
<script language="JavaScript" type="text/JavaScript">
 $(document).ready(function(){
   $("#select1").change(function(event){
      var id = $("#select1").find(':selected').val();
      window.open('pagina.php?id='+id,'_blank');  // changed here (cambiado aquí)
    });
 });
</script>
</head>
<body>
   <select name="select1" id="select1">     <!-- changed here (cambiado aquí) -->
      <option value='1'>opcion una</option>
      <option value='2'>opcion dos</option> <!-- changed here (cambiado aquí) -->
   </select>
 </body>

07-24 16:54