问题
Im using cordova 3.3.0 and i would like to open a local pdf file and then close it on user demand.
ref = window.open(encodeURI(path), '_blank', 'location=yes');
ref.addEventListener('exit', function() {
ref.removeEventListener('exit', function(){});
ref.close();
} );
This opens a file in inapp browser but i cannot get back to the actual app when I open some pdf file. How to add some close button or something ?
Im trying to get this working on ios.
回答1:
Long time since you asked this but just had exactly the same issue. I had to install the inAppBrowser plugin on my project and the Done button appeared. Without the plugin installed, the pdf opened but the Done button was not shown.
回答2:
What you have should work. On iOS a "Done" button should appear in the lower left of the screen.

function openPDF(){
ref = window.open('http://static.googleusercontent.com/media/www.google.com/en/us/webmasters/docs/search-engine-optimization-starter-guide.pdf', '_blank', 'location=yes');
ref.addEventListener('exit', function() {
ref.removeEventListener('exit', function(){});
ref.close();
} );
}
I tested on iOS 6.1 and iOS 7. Of course you can set location=no to remove the URL at the bottom.
来源:https://stackoverflow.com/questions/20884988/open-a-local-pdf-file-with-cordova