窗口上的Meteor回调.open(url)未打开窗口
Meteor callback on window.open(url) does not open window
如果有人知道window.open()
在Meteor.call()
的回调中不起作用,我会很高兴。您可以通过在客户端上的Meteor.call('method',argument,callback(e,r){...})
回调中调用window.open(url)
来轻松地重现这一点。在回调之外,它工作,在回调内部,window.location = url
正确地重定向。
我的数据库中有一些来自filepicker.io的安全URL。由于提前生成所有策略和签名的效率很低,所以我希望在有人实际尝试检索这些文件时,在单击事件中生成它们。不幸的是,在Meteor.call('methodname',param,callback(e,r){...})
的客户端回调中,window.open(url)
似乎不起作用,我不知道为什么。
模板
<template name="upload">
<div class="btn-group btn-group-vertical">
{{#each files}}
<button id="fp" class="btn btn-primary">{{filename}}</button>
{{/each}}
</div>
</template>
client/client.js
Template.upload.files=function(){
return files.find({});
}
Template.upload.events({
'click #fp':function(){
// window.open(this.url)
// if I uncomment the above line, a new window
// opens with the unsigned url
// (this.url is a valid mongo cursor)
Meteor.call('signedUrl',this.url,function(err,result){ // result is signed url
console.log(result); // loggs the correct url in the console
// window.location = result;
// if uncommented, the line above redirects correctly
window.open(result); // does NOT open the new window with the signed url
});
}
});
server/server.js
Meteor.methods({
signedUrl: function(url) {
// some proven-to-work-code that you can find at
// http://stackoverflow.com/questions/18546676
console.log(signed_url); // loggs the correctly signed url on the server
return signed_url;
}
});
提前感谢您的任何提示!向致以最良好的问候
这很可能被chrome/safari的反弹出过滤器捕获。
您可能希望以非恶意的方式使用新窗口,但现代浏览器需要用户输入才能打开新窗口。在回调中没有用户输入"触发器",所以浏览器可能会认为这是一个弹出窗口/广告。
真的没有太多的方法可以通过这个。您可以在运行回调时创建一个新按钮,然后要求用户单击它以打开一个新窗口。
相关文章:
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- asp.net MVC,重定向到视图,视图打开新窗口到外部url,它'It’’’’我们被当成一种风景
- javascript在退出时打开窗口url
- 如何在新选项卡中而不是在新窗口中打开URL
- 如何在传单.js中显示每个choropleth弹出窗口的唯一名称和URL
- 如何在 Node-Webkit 的同一窗口中打开 URL
- 表单按钮在同一窗口中打开新的URL
- 在Chrome中的适当选项卡/窗口中打开URL
- 如何使模式窗口打开动态内容并更改url
- 在d3.js中单击URL为的节点时无法打开弹出窗口
- 当我点击打开另一个弹出窗口时,如何强制关闭弹出窗口
- 如何在新窗口中打开url
- 通过程序在窗口中打开一个外部URL,链接会附加到网站上
- 使用自定义内容而不是url创建弹出窗口
- Javascript;html:有没有一种方法可以找到一个顶级的命名窗口(或选项卡)并将其带到前台,而不是将url加载到
- 爪哑脚本 |检查是否已打开具有特定 URL 的窗口
- 使用链接或键入URL关闭窗口
- html文档打开一个自定义大小的“;url”;窗口
- 为什么不开窗户呢?打开(url, name)在同一窗口与IE11打开
- Titanium Appcelerator中基于URL的窗口