Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open `tel:+48123` link client side without openning new window/tab in browser

I need to deliver the same behaviour if I clicked tel:+4842566 link by myself. The default telephony application should call the number nothing more.

I managed that besides that new tab opens. I wrote:

function Call(){
    window.open("tel:+4842566",'_blank');     
}

and this:

function Call(){
    window.open("tel:+4842566");     
}

and this:

  function Call(){
        document.getElementById('mymailto').click();
    }


<a href="tel:+48123456" id="mymailto" style="display:none"></a>

Results are the same. Computer calls the number but new tab is openned.

Question: Is it possible to invoke/open this link without new tab/window?

EDIT: Before I tried to run this client side I did it on server side but did not realise that when I deploy application it is not the client who will be calling:

public ActionResult Call(int id, string number) {
  System.Diagnostics.Process proc = new System.Diagnostics.Process();
    string formattedNumber = "tel:+48" + formatPhoneNumber(number);
    System.Diagnostics.Debug.WriteLine("NUMBER " + formattedNumber);
    proc.StartInfo.FileName = formattedNumber;
    proc.Start();
    Person person = db.Persons.Find(id);
    return RedirectToAction("Edit", new Person { Id = id });
}

but then I didn't get new tab, maybe it will help somehow.

EDIT 2: I don't simply look for href link cause launching tel: link is only one of 2 things that happen at the same time:

<p>@Html.ActionLink("Call Cell Phone", "Call", new { id = Model.Id, number = Model.CellNumber }, new { @class = "btn btn-default", onclick = "Call();" })</p>

I go to the controller action and invoke Call() javascript method and JavaScript method is the only place that simple openning any link can be done.

like image 489
Employee Avatar asked Sep 06 '14 19:09

Employee


1 Answers

The solution is much easier:

document.location.href="tel:"+the_number;
like image 148
Julian Avatar answered Sep 28 '22 09:09

Julian