iPhone浏览器标签和优化的网站
时间:2020-03-05 18:50:14 来源:igfitidea点击:
iPhone的浏览器标签是什么?iPhone优化的网站与普通的移动网站有何不同?
谢谢!
解决方案
回答
Nettuts对iPhone的网络开发进行了很好的介绍。你在这里找到
这是我们要求的特定代码(摘自该文章):
<!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"--> <!-- place iPhone code in here --> <!--#else --> <!-- place standard code to be used by non iphone browser. --> <!--#endif -->
回答
Apple在此处定义用户代理。
该字段在HTTP标头中的" User-Agent"键下传输
回答
苹果在这里为iPhone网页开发提供了一些出色的指导方针:
适用于iPhone的Safari Web内容指南
从我的简要阅读中,这里是要注意的关键元素:
- 由于屏幕较小,"视口"和滚动的工作方式略有不同。有自定义的META标记,当有人进入页面时,我们可以自动调整此标记。
- 当心使用框架集或者其他功能的页面,这些功能要求用户滚动页面上的不同元素,因为iPhone不显示滚动条。
- 如果我们希望人们在iPhone上为页面添加书签,则有一个自定义的META标签,可让我们指定一个53x53图标,该图标看起来比典型的favourite.ico更好。
- 避免使用依赖于鼠标移动或者悬停操作的JavaScript来使事情发生,因为它们无法在iPhone上正常工作。
- 有一些自定义CSS属性,可让我们调整文本大小并突出显示iPhone上超链接的颜色。
- HTML / Javascript还有其他一些关键功能,它们告诉我们也应该赞成或者避免。
回答
更好的解决方案:
* (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;
}