window.open()不加载页面

时间:2015-07-29 10:01:32

标签: java jquery ajax google-chrome

我想在新窗口/标签页中打开一个页面,但是当它打开页面时,请不要加载。

控制器:

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);
      },                   
  });
});

var'数据'返回网址。网址是正确的,但页面不会加载。如果我点击F5,只需加载。我使用谷歌浏览器。一些建议?

修改

我正在测试一些可能的解决方案而且我得到了它:如果我放window.open("www.google.com"),则会打开新窗口,其中包含以下网址:localhost:9000 /" mypath" /www.google .COM。我不知道它是否有帮助但是......

1 个答案:

答案 0 :(得分:3)

我认为如果你使用字符串url作为window.open的参数,它必须是一个绝对的url,如http://example.com。所以请确保您的数据是绝对网址,否则添加" http [s]://"在它之前。 有关window.open。

的参考the MDN documentation