如何打开自定义浏览器窗口来查看pdf或文本文件等文件? [英] How to open a custom browser window to view files like pdf or text file ?
本文介绍了如何打开自定义浏览器窗口来查看pdf或文本文件等文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我目前用来点击按钮打开自定义窗口的代码:
问题是如何在angularJS控制器中编写相同的代码,这样我就不必将角度部分绑定到锚标记的id,然后在点击时将其传递给this.id?如果我试图直接传递onclick它会抛出错误,不允许(这是正确的,因为它不能)。
我尝试过:
Here is a code which I'm currently using to open a custom window on click of a button:
The problem is how to write the same code in angularJS controller so that I donot have to bind the angular part to id of anchor tag and then pass it in on click as this.id ? If I try to pass directly in onclick it throws error that it is not allowed(which is correct as it cannot).
What I have tried:
<a id="{{d.applicantDocumentId}}" href="#" onclick="openAttachment(this.id)"></a>
function openAttachment(id)
{
var w = window.innerWidth;
var h = window.innerHeight;
window.open('@Url.Action("DocumentViewer", "Profile")' + "?docId=" + id, '_blank', 'left=' + w / 5 + ',top=' + h / 5 + ',width=' + (w / 5) * 3 + ',height=' + (h / 4) * 3 + ',toolbar=1,resizable=1');
}
推荐答案
scope.openAttachment = function(id){
var w = window.innerWidth;
var h = window.innerHeight;
scope.openAttachment = function(id) { var w = window.innerWidth; var h = window.innerHeight;
window.open('〜/ Controller / Actionresult?docId ='+ id,'_ blank','left ='+ w / 5 +',top ='+ h / 5 +',width ='+(w / 5)* 3 +',height ='+(h / 4)* 3 +',toolbar = 1,resizable = 1' );
}
window.open(' ~/Controller/Actionresult?docId='+id, '_blank', 'left=' + w / 5 + ',top=' + h / 5 + ',width=' + (w / 5) * 3 + ',height=' + (h / 4) * 3 + ',toolbar=1,resizable=1'); }
这篇关于如何打开自定义浏览器窗口来查看pdf或文本文件等文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文