Hi guys below are two fragments from my code:
case 'i_new_call':
{
if (oSipSessionCall) {
// do not accept the incoming call if we're already 'in call'
e.newSession.hangup(); // comment this line for multi-line support
}
else {
oSipSessionCall = e.newSession;
oSipSessionCall.setConfiguration(oConfigCall);
uiBtnReceive('Answer');
btnCall.disabled = true;
btnHangUp.disabled = false;
startRingTone();
var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown');
txtCallStatus.innerHTML = "<i>Incoming call from [<b>" + sRemoteNumber + "</b>]</i>";
showNotifICall(sRemoteNumber);
}
break;
}
My function is:
function uiBtnReceive() {
var btnAccept = document.getElementsByName("Accept");
btnAccept.onclick = function () { sipCall(bDisableVideo ? 'call-audio' : 'call-audiovideo'); };
}
}
Button:
<input type="button" name="Accept" style="margin: 0; vertical-align:middle; height: 100%;" class="btn btn-primary" value="Accept"/>
The problem is that when I create button with id of btnAccept it works. But when I am trying to use element name it doesn't triggered. Any idea how can I solve this.
getElementsByName
returns array
of elements
you will need to use index
to get the object
and attach event
.
function uiBtnReceive() {
var btnAccept = document.getElementsByName('Accept')[0];
btnAccept.onclick = function () { sipCall(bDisableVideo ? 'call-audio' : 'call-audiovideo'); };
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.