I have a plain html / javascript App (no Phonegap) that i use with a native Android App and a WebView.
In the JavaScript part i have to reload the current page in some situations. With my old Phone and Android 4.3 i just used:
document.location = "index.html"
with my new Phone (Android 5) this seems not to work anymore. It stil works to change the page i.E. when i am currently viewing "books.html" i can use the above code to navigate to "index.html". But when i want to reload the same page i am currently viewing, nothing happens.
I debugged the WebView with the chrome debugger, no errors, no warnings, nothing. In chrome on my pc everything works fine.
Please Note:
I tried the solution mentioned by Rajesh. Unfortunately it didn't work out of the box.
I came across this issue:
https://bugs.chromium.org/p/chromium/issues/detail?id=327728
Its necessary to set a WebViewClient on the webView to make it work:
webView.setWebViewClient(new WebViewClient());
document.location
method will not reload page it essentially make entry to session history and make separate visit to page.
it may be possible that some browser implementation restrict adding side by side duplicate entry to session history, thus preventing reload of page.
best method to reload page is
document.location.reload()
Related
I want my PWA to periodically update itself while it is running, not waiting for the user to refresh the page (e.g. on iOS 12 it is actually quite hard to trigger page reload of a PWA).
I know there is ServiceWorkerRegistration.update() method, but it's not supported by Safari.
So, are there any workarounds to get my ServiceWorker to self-update without page reload on iOS?
Additional information:
Currently I periodically poll version.json file in which I put current app's version, compare it, and force a page reload. It works fine, but it requires two page reload to get the new version (this + after the activated event to load the new app's assets).
Here's my current solution, if you need more context: https://github.com/dimaip/calendar/blob/master/app/serviceWorker.js#L31
ServiceWorkerRegistration.update() is supported by all browsers that support service workers, and should accomplish what you want.
If you wanted to confirm for yourself that it's actually supported in Safari, try running
reg = await navigator.serviceWorker.ready
reg.update()
in Safari's JS console, with the Network panel open. You should see a request made for your service worker after you run that.
So I have a site that uses a native app to authenticate a user. This is how it works.
I get a token and start polling the app service to check when the user has authenticated.
I use a URI appname:// to open the app for the user, and I provide a redirect link to the app, so that once the authentication is done the user is redirected back to the site.
This works perfectly fine on iOS safari, and using an anchor tag, solved the issue of opening the site in a new tab.
The problems I am facing now is when the user is using the site from Chrome for iOS.
The first problem was that the redirect link was opening in Safari instead of Chrome, however I fixed this by adding googlechrome:// before the redirect url, so having something like this googlechrome://mysite.com#anchor
However I still have the issue that googlechrome://mysite.com#anchor always opens in a new tab, which obviously reloads the site, thus the polling would not have been started, but if I manually go back to the previous tab, the polling is still ongoing and the user is logged in.
My question is: Is there a way to use this kind of URI redirect for Chrome for iOS to open in the same tab?
I found the solution to this.
So basically if you just put googlechrome:// without specifying a url after it, this will open chrome for iOS in the current tab.
I have a typical modern web-app, regularly shared on Twitter.
I recently noticed that, when opening our web-app in the Twitter internal browser, localstorage is deactivated, which breaks our app.
How could I break out of the Twitter internal browser and open the page in the default Android browser?
I haven't tried this but just a suggestion. You could take a look at this and give it a try.
At the end of the article, it says that the external app won't be invoked if triggered without a user gesture but I believe that the limitation won't be there in case of the In-App browser.
Well, I think it isn't quite easy to say Android via a WebView to open the Chrome Browser as this in-app browser could be a lot different.
What you could try, as mentioned in the article Here is to trigger a click on an anchor which is calling an "pseudo" intent and add the fallback_url .
There isn't much details provided but it could be a possible hack / workaround.
In your HTML
...
And with JS:
$(".open_me").trigger("click");
According to the article
Now the URL will get you to zxing.org if the app could not be found, or the link was triggered from JavaScript without user gesture
(or for other cases where we don’t launch an external application.)
If you're lucky it will open the fallback_url, but as mentioned before it is a WebView which isn't the same as the Chrome Browser, therefore it is possible that nothing happens.
You can use a iFrame in your HTML like this:
<iframe src="url.com" width="900" height=400"></iframe>
Have an application that is using a BrowserField. The web site that is rendered within it all works fine except for an issue where pages have a back button that executes the following javascript: history.go(-1);
The page itself in the browser does go back one but the BrowserFieldHistory object is not updated and there are no requests to either handleNavigation or handleResource (I guess because the page is already cached).
Because of this the application cannot determine when the user has gone all the way back to the first page loaded and subsequently the Blackberry hardware back key cannot be used in the same way it operates in the device browser application (pressing back either goes back a web page or if pressed while in the first page closes the screen).
Any ideas why history.go(-1) is not reflected in the history stack and/or why the application doesn't receive handleNavigation/handleResource events?
I am developing on Win7 (32bit) in Eclipse Helios, BB 1.5 JDK on the 9800 (Torch) simulator (OS 6.0.0 of course).
Thanks
James
I am very new to FB programming and JavaScript as well (a long time ASP.NET programmer). I am trying to use the JavaScript SDK to create a fangate. The page works perfectly when I run my page directly (http://wmssupportforum.com/FacebookPages/FacebookWMSJobs.aspx), but when it is pulled up from within my Fan Page (http://www.facebook.com/pages/WMS-Support-Forum/207356652683205?sk=app_143965989047095), it doesn't work, i.e. it doesn't Show my Liked div and hide my UnLiked div, etc.
I have no idea how to debug this from within FB...(when I render it in IE directly from my site, I can debug it, but when I try to debug the Fan Page version, IE's dev tools won't load the script to debug it...it just hangs).
Any help is greatly appreciated!!!
Thanks in advance,
Chad
UPDATE: It looks like the difference is only an issue in IE v9. I don't have the same issues in Firefox or Chrome. So in IE9, pulling my page up on one IE Browser tab directly at the page URL works, but when pulled up through my FB FanPage on another IE tab, it doesn't work...seems like it is hanging as the HTML tab in IE Developer Tools window just says Loading....
It's a webserver issue. Believe it or not, but by adding in a simple P3P header to your response will solve the IE issue. See: Cookie blocked/not saved in IFRAME in Internet Explorer and also http://www.hanselman.com/blog/TheImportanceOfP3PAndACompactPrivacyPolicy.aspx