Sunday, 15 March 2015

ios - Prevent UIWebView from showing UIPopoverController for tel links -


I am working on an iPad application with UIWebView (Deployment Target iOS 5.0 +).

UIWebView should nothing while tapping my user, email, address, and phone number.

I have a problem with phone number if the HTML page contains links like this: & lt; A href = "tel: 555-555-5555"> 555-555-5555 & lt; / A & gt; When UIPopoverController appears when the user taps this link

I've tried the following:

  • Turn off identification in the xib file for UIWebView < / Li>
  • webView.dataDetectorTypes = UIDataDetectorTypeNone;
  • Call JS - document.documentElement.style.webkitTouchCallout = "none";

    UIWebView Representative

    Do you have any ideas?

    This is the reason The special phone number link is not disabled that it is not an detected phone number, it is just a regular old & lt; A href = foo & gt; The link, which is a telephone link for its href attribute, is the correct way to disable phone code detection, as you set up the data type type Want to So if you have a phone number somewhere, somewhere in the web page text and you want to prevent links from being created, then webView.dataDetectorTypes = UIDataDetectorTypeNone; Keep using .

    If you want to disable all links that look like a phone number, you will need to execute the JavaScript after the page is loaded. Use the webViewDidFinishLoad method in your UIWebView [webView stringByEvaluatingJavaScriptFromString:] and pass in JavaScript to change the offending link. Here's an example JavaScript, which is all your Telephone style will replace the link by showing the phone number instead of the text number. You want a bit different, or you may want to completely remove the link from the dom.

      var links = document.getElementsByTagName ('a'); (Var j = 0; j & lt; links.length; j ++) {var href = link [j] .getAttribute ('href'); Var prefix = href.substring (0,4); If (prefix == "tele:") {var parent node = link [ja]. Prentanod; Var replacement node = document. CreateTextNode (href.substring (prefix.length, href.length)); ParentNode.replaceChild (replacement node, link [ja]); }}    

No comments:

Post a Comment