How to load local file via iframe inside html file in wkwebview? - ios

I am migrating UIWebView to WKWebview.
While I could manage to migrate most of the workflows.
I am stuck at one workflow that I am not able to load the local file ("file://") via iframe from the html file in WKWebview.
It was working fine in UIWebView.
Also if iframe source is "web-url" and not local, it is working fine.
I am not seeing any error or any message on the console.
I read on few thread that loading local data in iFrame is broken in WKWebView, most probably because "allowReadAccesstoURL" setting which i am passing for main html is not passed to iframe correctly.
I wanted to check if there is a way to load local file via iframe.
It is disappointing that Apple has broken the functionality without providing proper alternative.

I am finally able to resolve it.
Issue was that the readAccess path for the "LoadFileUrl" was not inclusive of the url that was being loaded as iframe.
What was irritating is that console log did not give out any detail related to the error and I was not seeing any network call like decidepolicy or anything for the iframe loading, which caused the confusion.

Related

UIWebView cannot read correctly some local HTML5 stuff

Here I come with a new challenge for you all, Objective-C developers:
I'm trying to load some HTML5 exports from Articulate into an UIWebView. Well, at first sight it's quite simple: just put the HTML5 resources into the project and call index.html.
Well, that simply doesn't work if the HTML5 resource have a complex javascript structure. Specially with <audio> and <video> tags.
Any idea?
I've been investigating for hours and the solution appeared with some lateral thinking:
If the main problem is that reading locally doesn't work, but the app requirements forces you to maintain the content offline, then let's serve the content locally!.
Here are the steps I followed to resolve this issue:
Embed a web server into your app (I prefer GCDWebServer)
Let GDCWebServer serve your storyline locally with: [webServer startWithOptions:#{#"BindToLocalhost": #YES} error:nil];
Use WKWebView to call your local web server with: [wkView loadRequest:[NSURLRequest requestWithURL:webServer.serverURL]];
Then you will see your Articulate storyline working perfectly in your app inside a window, with iOS8.
Hope this can help someone.

Google Analytics MIME type issue in Chrome using Rails 3

I'm adding GA to a Rails 3 app, which would normally be extremely simple, of course. I've added the GA JS snippet, which is rendering just fine. Everything works perfectly in Safari. In Chrome, however, it's giving me a console error: Resource interpreted as Script but transferred with MIME type text/html: "about:blank", pointing to the JS line that loads the ga.js file: s.parentNode.insertBefore(ga, s). Some things I've investigated:
I created a plan HTML page with the JS snippet, and it loads outside Rails in Chrome with no error.
The same HTML page, when put in /public, gives the error above.
The same HTML page, loaded in Safari from /public, doesn't give any error according to Firebug.
I tried the GA Debug extension in Chrome, but it remains silent, because ga.js isn't getting loaded.
Looking at the developer console in Chrome, I see a request for "http://www.google-analytics.com/ga.js" that seems to stay in "pending" state, and a redirect to "about:blank" seemingly initiated by http://www.google-analytics.com/ga.js, which makes very little sense.
So this seems to be related to Rails (since the snippet works in the HTML outside Rails), and doesn't affect Safari, but other than that I'm stumped. Hopefully I've just been staring at it wrong, and someone else will point out the obvious to me...? Anyone come across this before? Any ideas will be very much appreciated.
Came across this issue myself. "Disconnect" disabled share buttons on my site (g+, twitter and fb). Had to remove it to view the site properly.

How to get Back button working between remote and local jQuery Mobile pages?

I have a local jQuery Mobile project going (inside PhoneGap, thus file:// protocol) where I sometimes need to fetch external pages (using http://) from a server where the content too are jQM pages with almost identical markup (except for the content, which is generated from a CMS).
Setting $.mobile.allowCrossDomainPages to true gives me the page, and that is all right. Going Back, however, fails. I get stuck in a place where /www/index.html is not found on the server (like, doh, of course..). Is there a way to "remember" where I came from, taking me back to the local html page I originally came from?
We just added a docs page on PhoneGap in jQuery Mobile for RC3 that should help you out quite a bit:
http://jquerymobile.com/test/docs/pages/phonegap.html

Firefox question: Is it possible to create an html iframe which loads a document from my extension using the chrome://?

I was wondering if it is possible to create an iframe whithin a HTML document pointing to a XUL document whithin my firefox extension such like:
<iframe src="chrome://myextension/content/document.xul"/>
I am currently getting security errors when trying to do this. I've already tried the contentaccessible=yes flag in my chrome.manifest but it didn't work.
Is there any workaround to get this working?
Thanks.
No, web pages are generally not allowed to load chrome documents. contentaccessible=yes refers to images and scripts that are less regulated security-wise (they can also be used across domains). However, your extension has permission to load chrome documents - even into a content page. So doing something like this from your extension will work:
window.content.frames[0].location.href = "chrome://myextension/content/document.xul";
Not sure whether this will help you, depends on what you are trying to achieve.

sIFR seems to be loading correctly but not displaying text

I'm Using sIFR 3r436, and although I believe everything is set up correctly, and my console shows that the .swf font file is loading correctly, the HTML type is hidden but the sIFR type is not displaying. Below is a link to the site in question:
Schaffer's Website
Below is a link to a test site that uses exactly the same sifr-config.js, sifr.js, css, and swf files. And it works. The main difference between the two is the server that they are running on.
Schaffer's Test Site
I'm hoping that maybe somebody can see a problem that I'm unable to. Appreciate the help!
The server gives a 403 forbidden for the Flash movie – in other words, it does not load.

Resources