Cordova InAppBrowser PDF- iOS - ios

My code is working but not exactly the way I want. I'm using the plugin cordova-plugin-inappbrowser. I have an anchor tag to click and opens up a pdf. The code is as follows:
$("#lnkTools").click(function(e){
//e.preventDefault();
url = 'someExternalLink.pdf';
var options = {location: 'yes', clearcache: 'no', toolbar:'no', closebuttoncaption: 'DONE?'};
$cordovaInAppBrowser.open(url, '_blank', options);
}
The problem I'm facing is that, the PDF doesn't open if I don't exit the app, I have to exit the app first and get back in for the PDF to open up. What am I missing? When I try to use _system same thing, before it opens up the browser, I still need to exit the app first.
EDIT:
When I try to change the $urlRouterProvider.otherwise('/app/main'); in my app.js to $urlRouterProvider.otherwise('/app/login'); it's working, well. Why is this like this? when I place a $state.go('app.main') in my login controller, it loops. Is there any way I can get through this?

Related

Ability to prevent/stop loading 'Page load' in Cypress when clicked a hyperlink

In my Cypress test,
I need to test a link which downloads a .txt, .xlsx and a .zip file when clicked, but when I use "click()" to click the hyperlink, it starts a page load and expects a new action to happen as a result of clicking a link.
As an alternative to this I tried using the cy.downloadFile() to download the files directly through the link but the link I am using is dynamically generated hence I am unable to use that as well. Hence I want to store the newly generated link in the variable and then use it in cy.downloadFile() every time I run the test.
Are there any other ways to test a hyperlink or how to store the dynamically generated link every time the test is run?
Hi there i been through this problem before.
I think it is the same scenario where the cypress test runner just keep waiting page load event and not go to the next test command while file are successfully downloaded.
Add custom cy.window event to listen the click event and add timeout to "force" reload current page, you need to tweak the timeout value so it suitable for your test.
it.only('tes button download', ()=> {
// visit url
cy.visit("/spmb/list_nilaiseleksi");
cy.get('#wrap-button > .btn').click()
//download
cy.window().document().then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () { doc.location.reload() }, 5000)
})
cy.get(':nth-child(9) > .col-md-12 > .btn').click()
})
})
More details and discussion available here on cypress github issue :
https://github.com/cypress-io/cypress/issues/14857
I found a way to store the link of the element I want to click. Since I am able to store the link, I am able to solve the requirement by using cy.downloadFile().
cy.get('#selector', {timeout: 15000}).then(($input) => {
cy.downloadFile($input.attr('href'),'cypress/downloads','filename.csv')
});
For me, the problem was resolved after I added the download attribute to the link, This is changing the element in the DOM, but it keeps the solution simple:
cy.get('[href="download?type=php"]')
.then((el) => {
el.attr('download', '');
})
.click();

Ionic 5 capacitor/angular preview files from external url's

I have tried previewanyfile cordova plugin to open files from external url's in Ionic 5 application. It works well with android but on IOS I noticed sometimes it doesnt preview/open PDF files. Just a grey screen with the file name on it. But strangely some PDF files open.
file preview screen
previewProductDocument(url: string) {
const loading = await this.loadingController.create({
message: 'Loading document...',
});
loading.present().then(() => {
this.previewAnyFile.preview(url).then((res) => {
loading.dismiss();
}).catch((err) => {
loading.dismiss();
this.presentToast('Error previewing the document try later', 'danger');
});
});
}
This is the plugin I have used
https://ionicframework.com/docs/native/preview-any-file
capacitor version "#capacitor/core": "^2.2.0",
Noticed this behavior only in IOS simulator + on Real IOS device.
Any idea what is going on here?
Special character (%2F) in the link is the cause of the issue.
For a quick win; either change the link or sanitise before processing.
In this case url.replace('%2F', '/') should work.
However, another link may, probably, contain a different character. Without being 100% sure, it worth a try decodeURI, which is decodeURI(url).

Detect empty, new tab openings in Google Chrome

I just published a Google Chrome extension which loads background images into new, empty tabs. The plugin is found here in the Chrome Web Store.
For detecting new and empty tabs, I need to ask for "tab" permissions in the extension's manifest.json. This, however, gives the extension the permission to read the browser's history. Not all users will want this and we don't actually need it. Is there a way to detect empty tabs without this permission requirement? Currently our check looks like this:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
if (changeInfo.status == "loading" && tab.url == 'chrome://newtab/')
{ /* load background into tab */ }
});
If you want to customize the new tab page you should add this to your manifest:
"chrome_url_overrides": {
"newtab": "newtab.html"
}
Then place the script you are currently injecting into new tab pages as a <script> tag in the newtab.html file. That won't cause that permission message.

Cannot open webpage from flash button

I want to open a webpage from a flash button. I'm using adobe flash CS6, action script2.
Below is the code i have tried:
on (release, releaseOutside ) {
getURL("http://www.google.com", "_self");
}
It works fine when i test it in (Test Movie -> in flash Professional).
But it doesn't work when i test using (Test Movie -> in Browser) and also doesn't work after exporting it.
This is due to security measures. Change '_self' to '_blank' within your AS or set 'allowScriptAccess' to 'always' within your html. Refer to this page for more info.

Phonegap jqm Ajax load an external page without changes base domain of the navigation

I'm having an issue with the page changes... In phonegap it works once and on chrome it doesn't work.
This is the code I use to load an external page in the dom and open it. After moving away it get's removed from dom.
function changeToMypage() {
$.mobile.loadPage('http://mydomain/mypage.html', {
prefetch: "true"
}).done(function() {
$.mobile.changePage('#mypageid');
});
}
$(document).on("pagehide", "#mypageid", function() {
$(this).remove();
});
On phonegap it works the first time I navigate to the external page but when I navigate to a local page and back to the external page it stops working.(Reloads the current page in stead)
In chrome it never works. It seems to try and load file://indexpage.html#mypageid in the changepage
but this doesn't work because I'm using single page navigation.
I don't understand how the pageload appends the mypage.html to the dom to navigate to it with the pageid?
Using jQuery.mobile.navigate() solved my problem but this is a low level api method according to the JQM docs. Maybe someone could give some extra information why it works with this method and not with changepage?

Resources