Open window url in new window jQuery

1

I have this function that I call from a select.

function CambiarEstadoPedido(que,id,cod,estado) { //tareas del seleccionador
if(que=="cambiar_estado") { InsertarModal('Pedidos','Pedi_CEstado','ConsPedido',id,estado,'450','410'); }
if(que =="Albaran") { window.open('http://google.es','Continue_to_Application','width=200,height=400');
return false; }
if(que =="Eliminar") { alert('guay es eliminar'); }

}

The idea is to open a new browser window with a url but for some reason that I do not understand, the window does not work. How can I be wrong?

If I put an alert inside "that=" Albaran "" if it works, with what I understand that the code goes well there.

Thank you very much everyone for your help:)

    
asked by Killpe 24.08.2017 в 21:14
source

2 answers

3

The only option to not open the window is either que != "Albaran" or equal the browser is not opening the secondary window because it is asking you (usually put a message above to allow it). Here is an image of what I say:

And I'll leave here a jsfiddle so you can check it out.

PS: I do not know why you put jQuery in the title ....

You tell us.

    
answered by 24.08.2017 в 21:21
0

Here I leave you two ways to see if they help you.

$(document).ready(function(){
	
	var ruta = "http://www.google.es";

	// Opcion 1
	$("#enlace1").click(function(){

		
		$("#enlace1").attr("href",ruta);
	
	});

	// Opcion 2
	$("#enlace2").click(function(){

		window.open(ruta, 'Nombre Ventana');
  		return false;
			
	});

});
#enlace2{
  cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a id="enlace1" target="_blank" href="">Enlace 1 a Google<a/>
<br/><br/>
<a id="enlace2">Enlace 2 a Google<a/>
    
answered by 29.08.2017 в 22:11