87,921
社区成员
发帖
与我相关
我的任务
分享
<a onclick="window.open('tencent://message/?uin=10987654321');" href="javascript:;"><img src="images/QQonline.jpg" /></a>
<script type="text/javascript">
function openQQ(qq) {
var frame = document.getElementById('qq-frame');
if(!frame) {
frame = document.createElement('iframe');
frame.id = 'qq-frame';
frame.setAttribute('style', 'width:0;height:0;display:none;');
frame.src = 'about:blank';
document.getElementsByTagName('body')[0].appendChild(frame);
}
frame.src = 'tencent://message/?uin=' + qq;
}
</script>
<a href="javascript:void(0)" onclick="openQQ('123456789')">test</a>
<a onclick="window.open('qq_online.html');" href="javascript:;"><img src="images/QQonline.jpg" /></a>
再在新打开的qq_online.html里用你写的那个JS跳转:
<script type="text/javascript">
window.onload=function(){
window.location.href='tencent://message/?uin=10987654321;
setTimeout("self.close()",500)}
</script>
但发现打开了QQ程序之后窗口还是空白没关,所以后面加了个settimeout来控制自身关闭。
目前这个是基本实现了我想达到的效果了,不知道有没有更加好的方案。