简体   繁体   English

如何使用Ionic在Android中打开外部pdf

[英]How to open external pdf in Android with Ionic

I am working on an application, and I am facing a problem with Ionic1 , and it concerns opening a .PDF from an external URL in Android with Ionic. 我正在开发一个应用程序,但Ionic1却遇到问题,它涉及到在Android中使用Ionic从外部URL打开.PDF。 I tried many solutions given in this site and other sites but in vain. 我尝试了本网站和其他网站提供的许多解决方案,但徒劳。 this is an example of what I have tried: 这是我尝试过的一个例子:

in .html file: 在.html文件中:

<a class="item" href="#" onclick="window.open('http://www.xxx.pdf', '_system', 'location=yes')">

in .js file: 在.js文件中:

var ref = window.open('http://www.xxx.pdf', '_blank', 'location=yes'); 

can you suggest other solutions please? 您能提出其他解决方案吗?

You could use the cordova inapp browser plugin . 您可以使用cordova inapp浏览器插件

you can replace all window.open by inappBrowser; 您可以使用inappBrowser替换所有window.open;

window.open = cordova.InAppBrowser.open;

or you can just use: 或者您可以使用:

cordova.InAppBrowser.open('http://linktopdf.pdf', '_blank', 'location=yes');

or if you use ngCordova, you can use $cordovaInAppBrowser, 或者,如果您使用ngCordova,则可以使用$ cordovaInAppBrowser,

$cordovaInAppBrowser.open('http://www.xxx.pdf', '_blank', options)

take a look here: http://ngcordova.com/docs/plugins/inAppBrowser/ 在这里看看: http : //ngcordova.com/docs/plugins/inAppBrowser/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM