开发者

iOS - UIWebview - Comments stripped over 3G

I am requesting a webpage in a UIWebView that contains comments (which are integral as they contain hidden information that the UIWebView uses to adjust settings).

Over Wifi this works fine, however over 3G querying the source from the UIWebView (with开发者_运维知识库 Javascript) returns output with all white space and comments removed.

My first instinct is that it's the server applying compression but the client denies as much, could there be a setting in iOS that is requesting this, or perhaps the 3G network operator (O2 - UK in this case) is stripping stuff out.

Anybody seen this, or know of a solution?

Many thanks in advance!


It was indeed the ISP stripping out comments..... the way I resolved this was to get the client to set up JS functions inside the page that returned the responses originally hidden in comments (a much cleaner solution anyway).

Then retrieve the information with:

[webView stringByEvaluatingJavaScriptFromString:@"functionName();"];


You could always test with a tethered laptop in Firefox and set your user agent to something the UIWebView would send such as:

Mozilla/5.0 (iPhone; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile

Then you could just view source in your browser.


The ISP is looking at the headers and removing comments and whitespace to save bandwidth. You could embed this data into your markup tag with your own attribute. For example:

<div myDataAttr='id_123'>
 ...
</div>

Edit

You might also look at using the HTML 5 custom data attributes.

<div data-id='123' data-name='John'>
...
</div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜