求助:Skype Web Control的sdk.min.js导致IE中机器人无法运行的问题
Fix for Skype Web Control SDK IE Compatibility (getRandomValues Undefined Error)
The root cause here is that Internet Explorer 11 and older versions don't natively support window.crypto.getRandomValues—an API the Skype Web Control SDK depends on for initialization. Since you can't modify the sdk.min.js file directly, the solution is to add a polyfill for this API before loading the Skype SDK.
Step-by-Step Fix:
- Inject a polyfill for
crypto.getRandomValuesright before the Skype SDK script tag. This will patch the missing API in IE without altering the SDK itself. - Use the following code to cover both IE11 (which has a renamed
msCryptoobject) and older IE versions:
<span class="skype-button bubble " data-bot-id="vdasdsadsadyapzK5k-C7Zw9acGTpVddH9CCj8" data-color="#1C57D9"></span> <span class="skype-chat" data-color-message="#27D1F0"></span> <!-- Polyfill for crypto.getRandomValues - must load BEFORE Skype SDK --> <script> // Map IE11's msCrypto to standard crypto object if (!window.crypto && window.msCrypto) { window.crypto = window.msCrypto; } // Fallback for older IE versions with no crypto support if (!window.crypto?.getRandomValues) { window.crypto = { getRandomValues: function(array) { // Basic non-cryptographically secure implementation (works for SDK's needs) for (var i = 0; i < array.length; i++) { array[i] = Math.floor(Math.random() * 256); } return array; } }; } </script> <script src="https://swc.cdn.skype.com/sdk/v1/sdk.min.js"></script>
Why This Works:
- For IE11: We alias the browser's native
msCrypto(which has the samegetRandomValuesfunctionality) to the standardwindow.cryptoname the SDK expects. - For older IE versions: We add a simple fallback implementation of
getRandomValues. While this isn't cryptographically secure, it's sufficient for the SDK's use case (generating random identifiers for the chat control) and will allow the SDK to initialize without errors.
This approach keeps your existing Skype control markup intact, works seamlessly in Chrome (since the polyfill won't run in modern browsers), and resolves the IE compatibility issue without modifying the SDK file.
内容的提问来源于stack exchange,提问作者vikbehal
相关产品推荐
相关产品推荐

