How to launch Skype without being redirected by window.location in Javascript?

二次信任 提交于 2019-12-12 06:21:19

问题


I am not sure if this is possible or maybe I am just doing it the wrong way. What I want to do is to call a function which checks the database to get the skype id (user B) and verify if user A is login. If user A is login and a Skype ID for user B is found then start up Skype. If not, nothing happens. Sounds simple enough....

A function is called when a user (user A) click on an image button on a form.

For example on start.html

<a href="#" onclick="skypeme('var1','var2'); return false"><img src="images/chat.png" ></a>

skypeme is a javascript function like this:

<script>
function skypeme(a,b) {
    window.location = 'skypeme.cfm?a=' + a + '&b=' + b;
    }
</script>

which calls skypeme.cfm to do all the database checking:

check the database and see if user A is login.... 
if user A is login, check if user B has skype ID
       if skype id is found for user B do this
           <script language="javascript">
           window.location = 'skype:#skype_id#?chat';
           </script>
       else do nothing 
else user A is not login
    <script language="javascript">
    signin('#a#','#b#');
    </script>

The skypeme.cfm is doing its job and start up Skype when everything is checked out fine. However, the problem is when user click on the button on start.html, he is directed to a blank page skypeme.cfm (skypeme.cfm doesn't display anything but checking) then the skype starts.

Is there any way to do it so that when the user click on the chat button on start.html, he will REMAIN on the start.html page while skype.cfm check the database and kick up Skype with javascript code? This maybe something simple but I just can't get it to do that. Any help is appreciated. Thanks in advance.


回答1:


Use to redirect to the link

window.location = 'skype:' + phone + '?call';



回答2:


Instead of pointing window.location to skypeme.cfm, load it inside an iframe (you can either dynamically attach an iframe to the document or just change it's src). Redirecting the iframe to a skype: uri works just as fine.



来源:https://stackoverflow.com/questions/29312669/how-to-launch-skype-without-being-redirected-by-window-location-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!