Search code examples
javascriptphpskype

Adding skype button with variable user


I have a site that creates a profile page on the fly. I want to add a skype button to the page for each of the profiles - each profile having a different ID.

I have found this code:

  <script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>
  <div id="SkypeButton_Call_skypeid_1">
  <script type="text/javascript">
    Skype.ui({
      "name": "call",
      "element": "SkypeButton_Call_skypeid_1",
      "participants": ["skypeid"],
      "imageSize": 32
    });
  </script>

This is just pasted into a php file at the moment.

I need to change the skypeid on the fly - I can do it for the html bits easy enough since I have a php variable for skypeid.

How do I pass this variable into the javascript?


Solution

  • <script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>
    <div id="SkypeButton_Call_skypeid_1">
      <script type="text/javascript">
        Skype.ui({
          "name": "call",
          "element": "SkypeButton_Call_skypeid_1",
          "participants": ["<?php echo $skypeid ?>"],
          "imageSize": 32
        });
    </script>
    

    should be what you need. If you cant access that script directly define a global javascript variable and pass that to the script