我正在使用Skype构建一个快速的VOIP演示,当我按下呼叫按钮时,Skype应用程序会将焦点从浏览器中移开。您可以在此处尝试:http://developer.skype.com/skype-uris/skype-uri-tutorial-webpages ,其中有几个“在此处尝试”链接。当我点击这些链接时,我希望浏览器保持焦点。是否有办法做到这一点? 感谢。
http://pcsupport.about.com/od/windowsxp/ht/stealingfocus02.htm
您可以在新窗口中打开它,然后关闭新窗口并将焦点放回您的窗口。
类似这样:
a=window.open('skype:ohadcn?chat',10,10);
//i couldn't find a relevant event, onload() do not work for me here
//so i used setTimeOut, hoping that two seconds is enough to open skype but not enough to loose the user
setTimeout(function(){ a.close();window.focus();},2000)
function ASDF() {
document.getElementsByName("q")[0].focus();
setTimeout(ASDF, 1000);
}
setTimeout(ASDF, 1000);
仍然没有运气。
我尝试修改Ohad的脚本,使其在skype应用程序打开后在新窗口中重新打开教程页面。如果教程/控制台页面是窗口中唯一的选项卡,则可以正常工作:
a=window.open('skype:ohadcn?chat',10,10);
setTimeout(function(){
a.close();
a=window.open('http://developer.skype.com/skype-uris/skype-uri-tutorial-webpages', 10, 10);
window.close();},2000);