What is iPhone's browser tag and how iPhone optimized web site is different from a usual mobile web site?
Thanks!
What is iPhone's browser tag and how iPhone optimized web site is different from a usual mobile web site?
Thanks!
Nettuts has a great introduction to web-developement for iPhone. You find it here
This is the specific code you asked for (taken from that article):
<!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"-->
<!--
place iPhone code in here
-->
<!--#else -->
<!--
place standard code to be used by non iphone browser.
-->
<!--#endif -->
Apple defines the user agent here.
This field is transmitted in the HTTP headers under the key "User-Agent"
Apple has some excellent guidelines for iPhone web page development here:
Safari Web Content Guide for iPhone
From my brief reading of it, here are a key elements to look out for:
Better Solution:
*
(NSString *)flattenHTML:(NSString *)html {
NSScanner *theScanner; NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];
while ([theScanner isAtEnd] == NO) {
// find start of tag
[theScanner scanUpToString:@"<" intoString:NULL] ;
// find end of tag
[theScanner scanUpToString:@">" intoString:&text] ;
// replace the found tag with a space
//(you can filter multi-spaces out later if you wish)
html = [html stringByReplacingOccurrencesOfString:
[ NSString stringWithFormat:@"%@>", text]
withString:@" "];
} // while //
return html;
}