代码之家  ›  专栏  ›  技术社区  ›  sergeb

iPhone浏览器标签和优化的网站

  •  3
  • sergeb  · 技术社区  · 16 年前

    iPhone的浏览器标签是什么?iPhone优化的网站与普通的移动网站有什么不同?

    谢谢!

    4 回复  |  直到 14 年前
        1
  •  1
  •   Espen Herseth Halvorsen    16 年前

    Nettus对iPhone的Web开发有很好的介绍。你找到它 here

    这是您要求的特定代码(摘自那篇文章):

    <!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"-->   
    
    <!--  
    place iPhone code in here  
    -->   
    
    <!--#else -->   
    
    <!--  
        place standard code to be used by non iphone browser.   
    -->   
    <!--#endif --> 
    
        2
  •  2
  •   Tim Farley    16 年前

    苹果对iPhone网页开发有一些很好的指导方针:

    Safari Web Content Guide for iPhone

    从我对它的简要阅读中,可以看到以下几个关键要素:

    • “视区”和滚动的工作方式有点不同,因为屏幕尺寸小。有一些自定义的元标记可以让您在有人访问您的页面时自动调整它。
    • 请注意使用框架集或其他要求用户滚动页面上不同元素的功能的页面,因为iPhone不显示滚动条。
    • 如果你希望人们在iPhone上为你的页面添加书签,那么有一个定制的元标签,可以让你指定一个53x53图标,它看起来比典型的favorite.ico更好。
    • 避免使用依赖鼠标移动或悬停操作来实现的javascript,它们在iPhone上无法正常工作。
    • 有一些自定义的CSS属性允许您在iPhone上调整文本大小和突出显示超链接的颜色。
    • 还有其他关键的HTML/javascript特性,它们告诉您要么喜欢要么避免。
        3
  •  1
  •   Jason Cohen    16 年前

    Apple定义用户代理 here .

    此字段在“用户代理”键下的HTTP头中传输。

        4
  •  0
  •   Jimit    14 年前

    更好的解决方案:

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

    }