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 在这里提供了一些关于 iPhone 网页开发的优秀指南:

iPhone 版 Safari 网页内容指南

根据我的简要阅读,以下是需要注意的关键要素:

  • 由于屏幕尺寸较小,“视口”和滚动的工作方式有点不同。有自定义 META 标记,可让您在有人访问您的页面时自动调整此标记。
  • 请注意使用框架集或其他需要用户滚动页面上不同元素的功能的页面,因为 iPhone 不显示滚动条。
  • 如果您希望人们在 iPhone 上为您的页面添加书签,可以使用自定义 META 标记来指定 53x53 的图标,该图标看起来比典型的 favorite.ico 更好。
  • 避免使用依赖鼠标移动或悬停操作来实现操作的 JavaScript,它们无法在 iPhone 上正常工作。
  • 有一些自定义 CSS 属性允许您调整 iPhone 上超链接的文本大小和突出显示颜色。
  • 还有其他关键的 HTML/Javascript 功能,它们也会告诉您应该支持还是避免。

苹果定义了用户代理 这里.

该字段在 HTTP 标头中以“User-Agent”键传输

更好的解决方案:

*

  (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;

}

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top