Does UIWebView auto prefetch pages? - iphone

Does UIWebView auto prefetch pages?
This is my situation:
The main page is a local HTML file containing 3 links to other local HTML files. In one of them I have an iframe that loads a page from the Internet. Could the UIWebView be attempting to prefetch this page silently?
I'm inclining to no, but I haven't found a definite answer yet.

UIWebView mimics a browser page, so if you open a local file which has an iframe that references a remote page then yes the iframe will attempt to load the remote page but not until that page is loaded as the WebView's active html page.

Related

InAppSettingsKit UIWebView

How do you add a UIWebView (to load a live site, not an HTML page) to show as a sub-view of IASK?
I see this example in the sample app, but it is using a static local page.
Just put the http:// URL of the page into the File key instead of your local file name.

Cross-domain cookies in iframe Safari

I have a problem with setting cookies in an iframe (which loads a site from another domain).
On my site X.COM I load <iframe src='Y.COM'>
Y.COM tries to set cookies, but Safari blocks they, as this site was not visited before. So loading Y.COM fails because it can't work without cookies. Is there a way to solve this issue?
P.S. I cann't modify any data at Y.COM.
P.S.S. Also we can modify Safari's settings - "Accept cookies" = "Always", but it is not a solution for me - it seems to be impossible to lead every user to do it..
I experimented a similar problem. A web "parent" page open my "child" website in a jquery fancybox i-frame cross-domain. Not problem at all with Explorer, Chrome, Firefox, Opera and even with Safari (5.8.1) on MAC. But with iPhone, iPad and mini iPad, the session in the i-frame is lost.
That's mean that at every click on an element in the i-frame (web site is in aspx) a new session started.
We solve the problem in a very simple way:
when the parent website start, it call a page in the child site directly (not in an i-frame). In this page I just set a session variable and I redirect to the parent website. Now when the child website is open in an iframe, the session is kept.

UIWebViewDeletate shouldStartLoadWithRequest: gets called multiple times with redirection requests

I'm using a UIWebView to display html pages which contain links, some of the links are to local files (file://...) and some are to remote web site (http://... ).
For some sites shouldStartLoadWithRequest gets called twice, for example if the html contains:
<a href="http://www.zagat.com/Verticals/PropertyDetails.aspx?VID=8&R=36121">
Then shouldStartLoadWithRequest gets called as expected with a request of
"www.zagat.com/Verticals/PropertyDetails.aspx?VID=8&R=36121"
But then it gets called again but this time with a redirection request of
"http://zagat.mobi/"
Is it possible to get feedback from the UIWebView when this is happening?
This happens when a site redirects you to their mobile version. I just tested this in the Safari iPhone App with the link you posted and it indeed redirects to Zagat's mobile site. Some websites are smarter than others as to where you get redirected. You can force the page to load the non-mobile version by not allowing redirects.

webkit .appcache file caches dynamic page

The main page of my mobile web app is a .jsp page. My app requires login (Google App Engine), so there is a Log In button when the user is not logged in and a Log Out button when the user is logged in, all handled by code on the .jsp page.
I load a lot of JS code on the page, so I used a .appcache file to cache that. Unfortunatelly, even though I added my .jsp page to the Network area, the page is being cached in a funny way, ignoring the content server from the server. That means that my Log Out button shows when users are Logged Out and vice-versa.
I tried to add no-cache directives as meta tags, but they are all being ignored.
Ideas?
According to dive into HTML5, the page that references the manifest is automatically included in the manifest.
http://diveintohtml5.ep.io/offline.html
Q: Do I need to list my HTML pages in my cache manifest?
A: Yes and no. If your entire web application is contained in a single page, just make sure that page points to the cache manifest using the manifest attribute. When you navigate to an HTML page with a manifest attribute, the page itself is assumed to be part of the web application, so you don’t need to list it in the manifest file itself. However, if your web application spans multiple pages, you should list all of the HTML pages in the manifest file, otherwise the browser would not know that there are other HTML pages that need to be downloaded and cached.
I have a similar issue, and I think I will end up loading the contents of the page via AJAX.
Caching in appCache is a two stage process: first the cache manifest is checked (in this case, as the page is loading), then if the content of it has changed, that content is reloaded. However, in your case, by that time, the stale page is already loaded and displayed.
The easiest fix would be to specifically exclude the page (but not the .js) from the appCache, so that only the js is cached, and not the page. I sounds like you might have figured that out, as you are trying to do it by putting the page in the network area. Check that that exclusion is correct, as that sounds like the problem, and that html cache attributes are being set correctly on that page.

Just can't seem to fetch the mobile Gmail html, what is wrong?

I'm trying to cache the mobile Gmail webpage because UIWebView does not cache the content itself (mobile safari does, but not UIWebView).
I tried the methods listed here Reading HTML content from a UIWebView basically saving the html either directly from URLRequest or from UIWebView itself. When I try to put the html saved back into UIWebView it is not the same page!
This is the page that I want to save
alt text http://img39.imageshack.us/img39/5679/screenshot20090830at123.png
This is the page that the html saved will display
alt text http://img39.imageshack.us/img39/8734/screenshot20090830at122.png
If you're loading using loadData:MIMEType:textEncodingName:baseURL: make sure you're setting baseURL correctly - that way, the WebView will know where to look for relative stylesheets and so on.
Edit: For example, if I was saving this page, I'd set the base URL to Just can't seem to fetch the mobile Gmail html, what is wrong?.
That looks like the same page to me, but with different stylesheets attached. If you're just re-displaying identical HTML from your local server, the relative stylesheet paths in Google's HTML would no longer be correct. Also, any AJAX requests meant to run after the page loads would no longer work (both because the relative paths to the scripts would be wrong, and also because Cross-Site Scripting restrictions would prevent them from contacting Google).
Attempting to scrape content from an AJAX-enabled application is no small undertaking. You'd have to replicate a lot of GMail's functionality to truly reproduce the exact page Google presents.