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

iphone/ipad webapp的禁用格式检测不起作用

  •  5
  • Marks  · 技术社区  · 15 年前

    我有一个webapp,它在iphone/ipad上显示许多识别为电话号码的长号码。我使用了苹果引用中提到的meta标记来禁用它:

    <meta name="format-detection" content="telephone=no"/>
    

    但如果正常加载或重新加载页面,则此操作不起作用。当我用ajax重新加载页面的一部分时,它突然起作用,并且数字是普通文本。但当我重新加载页面时,这些数字又变成了链接。如果ajax加载的内容与ajax请求之前的位置完全相同,也会发生这种情况。

    如果我在浏览器(不是webapp)中查看页面,它会从头开始工作。

    你知道为什么会这样吗?我该怎么解决? 有没有其他方法可以强制数字不是链接。

    谢谢你的帮助。

    3 回复  |  直到 15 年前
        1
  •  4
  •   Peter Smeekens    15 年前

    尝试将此添加到projectappdelegate.m

    // ...
    
    - (void)webViewDidStartLoad:(UIWebView *)theWebView 
    {
        theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;    
        return [ super webViewDidStartLoad:theWebView ];
    }
    
    // ...
    

    为我做了个诡计…

        2
  •  0
  •   Mike    15 年前

    我也遇到过类似的问题,一个嵌入的网页在浏览器中运行良好,但当嵌入到一个应用程序中时,问题就出现了。这是由于应用程序本身的设置重写了元标记,请参见 http://developer.apple.com/iphone/library/documentation/uikit/reference/UIKitDataTypesReference/Reference/reference.html#//apple_ref/doc/c_ref/UIDataDetectorTypePhoneNumber 是的。

    可以帮忙吗?

        3
  •  0
  •   Joseph Wright    12 年前

    您可能需要完成将应用程序添加到主屏幕书签的整个过程,以强制更新缓存。

    你也有正确的代码 format-detection according to Apple's guide to Apple-specific meta tags 但它们没有带尾随斜杠的自结束元标记:

    <meta name="format-detection" content="telephone=no">
    
    推荐文章