开发者

Click-to-call on BlackBerry

I have a site that displays telephone numbers and email addresses. The aim is to enable the user to simply click on the tel or email to complete the action.

Currently i have a .php file that creates the URI for the tell or email and track the actions. So i have the following in my html for the link that the user will see:

<a href="track.php?" target="_self">Contact</a>

track.php then determines if its a call / email / website and sets a $location var (Either a tel:1231231234 / web:www.test.com / mailto:address@test.com). If tried returning it / doing the redirect in the following ways:

1.

echo '<script type="text/javascript">
        window.location="'.$location.'";
      </script>';

2.

header('Location: ' . $location);
开发者_C百科

3.

echo '<script type="text/javascript">
        header.location="'.$location.'";
      </script>';

All of these methods work on iPhone / Android / Symbian devices, but not on blackberry (I've tested with a BB Curve 8520).

If i hardcode the links (see code below) and click on it directly it works 100%, but as soon as i do the redirect it gives me a "Protocall not supported..." error.

    <a href="tel:xxxxxxxxx">Phone xxxxxxxxxx</a>
    <a href="mailto:xxx@xxx">Mail xxxxxx@xxxxxxx.co.za</a>
    <a href="web:xxxx">Open link www.xxxxxxx.co.za</a>
    <a href="sms:xxxxx">Send SMS to xxxxxxx</a>

Any suggestions / solutions / workaround?

PS. I did try it with and without the <meta http-equiv="x-rim-auto-match" content="none" /> meta tag. Still gives the same error.


Unfortunately I don't have a BlackBerry to test with, but here is something you can try:

Use a synchronous XMLHttpRequest call (i.e. AJAX but without the "asynchronous" part) to call your tracker. In this case, your track.php doesn't need to redirect at all, because it is called in the background.

<script type="text/javascript">
function callURL(url) {
// I'll assume you don't have IE on your BlackBerry, and that you can just use the native XMLHttpRequest object
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send();
</script>
<a href="tel:xxxxxxxxx" onclick="callURL('track.php');">Phone xxxxxxxxxx
</a>


The Blackberry browser (OS 4 and 5) has very flaky support for XMLHttpRequest. Worth a try. We worked on this ages ago.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜