Make an <a> link or <button> automatically start dialing - javascript

I'm assuming there's got to be a way to get an <a> tag to automatically dial a phone number, because Google does it, but how?
Just using a tel: href opens a dialer, but it doesn't begin the phone call like when you click on the "Call" button (see below) from Google search results on mobile.
It looks like they're using JS to achieve this, but I'd love to know how so we can implement this into our call links on client websites. Clicking a button to call and also having to click the "dial/call" button in your dialer creates an extra barrier for conversions that I'd love to see eliminated. Any help is greatly appreciated!
Looked up a local guitar shop that I clicked to call yesterday (which automatically started the phone call) and opened the inspector. The call link html is highlighted.

This behavior is OS / Browser combination dependent.
The reason this works in your screenshot is the use of Google Chrome on a Google (Android) device. If you observe the same link using FireFox on android, or Safari on IOS you see different behaviors.
For more information reference the use of Intents

Related

Force Open External Browsers instead of any in-app browser [HTML/Javascript]

I've already researched and found a lot on this topic, but there's an idea that I still couldn't find and wanted to see if it's possible.
A bit of a background, I'm not a back-end developer and I'm not as well versed in it. But I have written a small website using HTML, CSS & Javascript (jQuery).
In-app browser is a problem for me since I am using localStorage to store some information for the user, and being its in-app then the user will lose all those details once they leave instagram, for example.
I've come upon a few results, and some here on stackoverflow, but some answers did not work (link 1, link 2) and most answers said that this is not possible anyway.
So I was wondering (and I'd take this as a learning experience) about the following use case:
Let's take Instagram as the example here. If we set in our bio the link to youtube let's say, the youtube website will display at the top "Open in App" button, which in that way can then open the native youtube app and the user can continue normally. In that sense, isn't it possible to let's say, to create a button like "Open in Safari", and once the user opens my website they will be able to tap it and it would open the safari app with its appropriate link? Or is this not possible also since it should be coded from Safari's end?
A URL Scheme is what you need. for example:
Google Chrome:
googlechrome://domain
Safari:
safari-https://domain
Firefox:
firefox://open-url?url=domain
Opera:
opera-https://domain
X Web:
x-web-search://search+term

Cocoa: WKWebView / WebView cannot open links inside Gmail or Inbox

I am the developer of Boxy, a famous native wrapper around Inbox by Gmail, and wanted to ask if anyone is able to help with something I have been struggling with since day one of development.
Here is the problem: links on inbox.google.com and gmail.com work differently than on other sites: clicking on them does not trigger a navigation action on my webview (I am using a WKWebView specifically, but the problem is also present using the old WebView). So I am having a difficult time opening links in an external browser when appropriate.
Because of this, at the time of this writing, I am relying on a terrible hack in order to open links: intercepting clicks on the document.body with javascript (using an event listener) and then forcing them to open on the external browser by calling the native app.
My best guess is that the Gmail/Inbox apps perform some javascript magic in order to track clicks on all the links inside emails and that, somehow, this interfers with the standard behaviour.
Has anyone got any idea how I can solve this problem?
Things I already tried
Implementing the method -webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures: of WKUIDelegate. Did not work: the method is called but the request associated with the navigation action is empty.
I found a solution. This issue is due to when clicking link, instead of opening using target=_blank, Gmail attempts to open an about:blank window and then run javascript to redirect the link.
You need to make sure that Gmail can correctly receive the handle of the created window.
- (WKWebView *)webView:(WebUI *)webView
createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration
forNavigationAction:(WKNavigationAction *)navigationAction
windowFeatures:(WKWindowFeatures *)windowFeatures
You need to make sure this delegate method correctly returns the newly created wkwebview.

iPad - window.open("tel:555", "_top") is not invoking default behavior

I'm developing an mobile site and need to invoke a phone call on mobile at the touchend event. On iPhone and Android the window.open('tel:555', '_top') is working fine, invoking a phone call.
On iPad, the default behavior is to offer a "Add to contacts" or "Copy" option. When using a link, it's working fine, as in <a href='tel:555'>555</a>
When trying window.open('tel:555', '_top') on iPad I'm getting:
Cannot Open Page
Safari cannot open the page because the address is invalid.
I've also tried setTimeout('window.location="tel:555";', 500); from How to trigger click-to-call with javascript (iphone), same problem.
Is there a way to invoke the default behavior with Javascript?
I believe this is the correct behaviour.
In the Apple URL Scheme Reference they specifically say that...
If the Phone application is not installed on the device, opening a tel URL displays an appropriate warning message to the user.
I would assume that an iPod Touch would also produce a similar error.

How do I invoke a click on the google search button in webview android SDK?

I'm making an android app that consist of a webview & a button.
The webview will load google.com on startup & your supposed to be able to type anything you want into the google search box, then click on the "Search" button at the bottom of my app & it will invoke a click on google's "Google Search" button that's on the page inside the webview.
Here's the problem... I'm fairly new to android development & I don't know how to getelement classname invoke a click on a button that's inside of the webview by clicking a button on my layout.
Here is the code for the "Google Search" button...
http://pastebin.com/NCvnAvb1
Also, below is a diagram to what the main.xml layout looks like
http://i44.tinypic.com/21jp09g.png
Please post a reply if you know the code so I can type something into the search bar then click on my layout's search button & it will search google.
Thanks.
EDIT: I now have this code...
but it's telling me "document cannot be resolved"
webview.evaljs(document.getElementsByClassName("google search button blah").click());
however now eclipse is telling me "document cannon be resolved".
Anyone know how to fix that?
In my opinion, your approach is a bad idea. It would be possible to achieve what you're asking, but, (and I haven't thought about how to achieve it) your result would be fragile. There are about 2843 things Google could change which would break your code.
There is an official Google API you can use but you're limited to 100 free queries per day unless you sign up for Google billing, in which case Google might charge you for more searches.
Alternatively, you could provide your own search box, perhaps in a layout that looks like the Google home page, then construct the search URL and pass it back to Google.com
You might want to consider using Yahoo/Bing instead as they provide unlimited queries. See here for a good overview.

show browser preferences & Page Setup using javascript

Is there a way to use javascript to activate the preferences dialog, so that a user can change a proxy address if they need to & also be able to click on an anchor link and have the Page Setup Dialog open, so that they can choose the page orientation for printing.
The reason for this, is becuase I am trying to use mozilla Prism to deploy a web application, but I have hidden the Navigation Bar & Status Bar(which contains the Prism's button for setting these preferences). I want Prism to be just a frame.
I have not posted in Prism discussion forums, becuase maybe there is standard javascript way of opening up these dialogs, can you(anyone) share how if it is possible. A firefox workaround will be enough, since prism is based on Firefox. Thanks.

Categories

Resources