4
I am trying to open a link in a new window/tab but when it opens it does not load.
Controller:
public static Result loadCreateArtigo(){
return ok(request().host()+request().path());
}
Javascript:
$.SmartMessageBox({
buttons : '[Não][Sim]'
},
function(ButtonPressed) {
if (ButtonPressed === "Sim") {
Controller.loadCreateArtigo().ajax({
success: function(data){
window.open(data);
},
});
});
The data variable returns the url. What happens is that it opens a new tab with the right url but the page does not load. if F5 gives the page right click. I’m using Google Chrome. Any suggestions?
Dude, try passing the parameter
"_blank"
along ->window.open(data, "_blank");
– Jéf Bueno
I have tried this but it does not work. I have found the solution. window.open() must receive an absolute url, so if the host received on the date does not contain http[s], it is necessary to add it: window.open("http://"+data);
– Hugo Machado