»
S
I
D
E
B
A
R
«
Disabling ‘Action’ Alert in UIWebView
May 5th, 2009 by Anish Kumar
UIWebview Action Alert

UIWebview Action Alert

If there is an <a href></a> tag in the html that is being loaded in an UIWebView, then touching that link for few seconds would trigger an alert showing ‘Action’ or the alternate text provided for the link.

If we need to disable it, then we need to set

document.documentElement.style.webkitTouchCallout=”none”;

This can be called in the onload event of the html <body> tag which is being loaded in UIWebview. Put this piece of Javascript before the <body> tag

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Hide Action Alert In UIWebView</title>

<script type="text/javascript">
function OnLoad()
{
   document.documentElement.style.webkitTouchCallout = "none";
}
</script>
</head>
<body onload="OnLoad()"/>
</body>
</html>
About Me: Anish:
Mac OS X software development is my bread winner with over 6 years of experience. Expertise in Color Management, TWAIN Scanner drivers on Mac OS X, Photoshop Filter and Import Plugin development on Mac OS X, iPhone. As an hobby I love to work on PHP, Flex, AIR, Photoshop. Check the 'About' page for more.

2 Responses  
HZC writes:
May 10th, 2009 at 7:12 pm

“… an alert showing ‘Action’ or the alternate text provided for the link.”

I’ve tried using the title attribute of the anchor a tag, but the UIWebView still shows as its title the text between the opening and closing a tag followed by the URL in the href attribute.

How can I keep the callout but customize what shows up there?

Matt Dolan writes:
June 24th, 2009 at 2:34 pm

You will also be able to do this through CSS:

body {
-webkit-touch-callout: none;
}

This and other Webkit/Safari/iPhone specific CSS can be found in Apple’s documents at http://developer.apple.com/DOCUMENTATION/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html

Leave a Reply

Spam protection by WP Captcha-Free