UIWebView sometimes displays HTML code instead of rendering - html

One of my testers for an app that loads URL's in a UIWebView, reported that sometimes, instead of seeing a normal, rendered webpage, he saw the HTML code for it (like he would be viewing the source of the webpage).
Does anyone know in what case this would happen?
One of the possibilities that my team was throwing around was that there could be some invalid HTML/JS that couldn't be parsed correctly.

Related

Images in HTML file not being displayed on iPhone

I made some simple HTML files and tried to open them on my iPhone, in both the files app and some third party HTML viewer apps from the App Store, but the images are not being displayed, not a single one.
It‘s not because the image is in another folder or the file path is incorrect, I‘ve checked all that. Also I‘ve looked up the issue and it seems that this might be caused by too large png files, but I tried to resize the images and also changing them to jpg, but still didn‘t work. So what could be the issue here?
I‘ve attached an image of the result that I get with this example code (the png file is in the same folder as the HTML file):
<html>
<head>
</head>
<body>
Test
<br>
<br>
<img src="image.png">
</body>
</html>
Result
This is almost certainly a security related issue.
I ran into this helping a friend who was working on an email newsletter and sent it to herself as an attachment. Opening in gmail showed the same behavior - no images.
So I tried saving the file to the Files app and opening it. Same thing. Loading the page from a web server it worked n
It doesn’t entirely make sense why they need to be so strict - the same thing in a desktop browser would show images. But I don’t think there’s anything you can do in this case.
Saving as a complete web page archive may work if the goal is to email an attachment that someone needs to open - but that’s not a common thing to do and if you send the message as a real email it’ll work fine.

iOS - HTML source is different than when inspecting element in Chrome on desktop

I am trying to get the html of a website to put in my iOS app. When I log the html from an NSData variable through an NSURLConnection, the html is different if I then went to the website on my desktop and clicked inspect element on the element that I am trying to find in the iOS html. Why would it be different? Is it because I clicked specifically on that element? It looks the same on iOS and the desktop because I have it loaded into a UIWebView.
Update: I have been told that in Chrome it is the rendered source code. How can I get the rendered source code in iOS?
In Chrome's Developer Console, it's showing rendered source codes (after AJAX and extension's modifications). Code mistakes (such as unclosed tags) will be fixed too.
It's NOT your original source code.

Issues on chrome showing an embedded PDF

I have the following code in a html document:
<p>PDF sample</p>
<object data="http://www.whateverdomain.com/whatever/~/media/sample.pdf" type="application/pdf"></object>
This is working in IE, Firefox but not in Chrome. Appears a grey box in the browser with no embedded pdf. When I check on "network" tab in chrome I'm receiving a HTTP 200 response but PDF is not shown.
I tried URL encode tilde "~" symbol replacing it by %7e but still its not working on Chrome.
I don't have the possibility of changing the url which is provided by an external service.
Do you have any clue on how to solve ?
You might wish to try and use a simple iframe. At the very least I am pretty sure that works for chrome, might not work for IE though. Another alternative is using the Google Docs viewer, with that you are sure to be cross browser compatible, although some pdf's might not render perfectly. The last option you have is using something like pdf.js to render the pdf's yourself inside the browser. Gives you a lot of control and ensures that even people running computers without a pdf viewer installed (or a native pdf viewer like chrome and firefox) will be able to view the file.

Webpage stuck in loading in Chrome

My webpage gets stuck in loading in Chrome (the little spinning icon on the page tab, and the mouse cursor also stuck in loading version), but the odd thing is everything in the website displays fine. This doesn't happen in Firefox or IE.
Does anyone have any theory to what's causing it? Is it because some asset doesn't exist? For example:
<img src="pic.png">
But "pic.png" doesn't exist?
If that's the case how do I check the code to make sure all assets, including css/js/img/sound/video files all exist as linked from the document? My html file is huge, going line by line and checking would take forever.

Problem with displaying Smarty template in Internet explorer

I have converted my existing website to Smarty template (my very first project with 1 day of smarty experience under the belt)
Prior to conversion my website looked fine in IE and FF.
After the conversion FF still looks okay however in IE everything falls apart.
I have tried comparing the source code in IE and FF and everything looks exactly the same.
Any help is appreciated.
Since Smarty is just the templating system that generates the HTML sent to the browser, the issue probably occurred when you split up your existing site into parts. Unfortunately it isn't very easy to find out what is wrong with a full project on SO. That said, here are some tips on debugging the issue.
Load your old site and copy the source from the browser (doesn't matter which browser as the server sends the same HTML*).
Load your new site and copy the source from the browser.
Diff the two sources to find the differences.
I think that's the best place to start. If the new site is sending the exact same HTML to the browser, then it would seem that some resource isn't being loaded (bad link) or javascript isn't being executed in IE, which should be separate from Smarty. For that check IE's Developer Tools and make sure no CSS is getting a 404 and no js exceptions are being thrown.
*As long as you aren't modifying things on the server based off the User-Agent sent, which is not common.