背景
js调用第三方公司提供的客户端,如果客户端未启动,则需要自动启动客户端,客户端启动方式为a标签,href指定本地协议链接
解决思路
客户端未启动,则动态创建a标签启动客户端,然后初始化客户端数据
关键代码
var a = document.createElement('a');
a.setAttribute('href', href);
a.setAttribute('target', '_blank');
a.setAttribute('id', 'startTelMedicine');
// 防止反复添加
if(document.getElementById('startTelMedicine')) {
document.body.removeChild(document.getElementById('startTelMedicine'));
}
document.body.appendChild(a);
a.click();