|
| 1 | +<!-- Working: |
| 2 | +1. Create a <div> on your page and assign it an ID (e.g., widget-container) |
| 3 | +2. Set the desired width and height on that div |
| 4 | +3. Pass the div ID into the Kommunicate settings via the containerId parameter and replace App-Id with your actual App Id |
| 5 | +4. The chat widget will automatically take the dimensions of the div and open on page load --> |
| 6 | + |
1 | 7 | <!DOCTYPE html> |
2 | | -<html lang="en"> |
| 8 | +<html> |
| 9 | + |
3 | 10 | <head> |
4 | | - <meta charset="UTF-8"> |
5 | | - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 | | - <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
7 | | - <title>Kommunicate Script</title> |
| 11 | + <meta charset="UTF-8" /> |
| 12 | + <title>Kommunicate Container Test</title> |
8 | 13 | </head> |
| 14 | + |
9 | 15 | <body> |
| 16 | + |
| 17 | + <!-- Custom Container --> |
| 18 | + <div id="widget-container" style="width: 700px; height: 600px; border: 1px solid #ccc;"> |
| 19 | + </div> |
10 | 20 | <script type="text/javascript"> |
11 | | - (function(d, m){ |
12 | | - var kommunicateSettings = {"appId":"1c59bc4cac28d23cd3c21c876e60be920","conversationTitle":"Vibhor Sharma", |
13 | | - "onInit": function() { |
14 | | - var iframeStyle = document.createElement('style'); |
15 | | - var classSettings = ".change-kommunicate-iframe-height{height:100%!important;width:100%!important;right:0!important;bottom:0!important;max-height: 100%!important;}"; |
16 | | - iframeStyle.type = 'text/css'; |
17 | | - iframeStyle.innerHTML = classSettings; |
18 | | - document.getElementsByTagName('head')[0].appendChild(iframeStyle); |
19 | | - var launcherIconStyle = "@media(min-width: 510px){.mck-sidebox.fade.in,.mck-box .mck-box-sm{width:100%; height:100%;max-height:100%!important;border-radius:0px!important;}.mck-sidebox{right:0!important;bottom:0!important;}}"; |
20 | | - Kommunicate.customizeWidgetCss(launcherIconStyle); |
21 | | - var iframe = window.top.document.getElementsByTagName("iframe")[0]; |
22 | | - var addClassToIframe = iframe.contentDocument.getElementById("kommunicate-widget-iframe"); |
23 | | - addClassToIframe.classList.add("change-kommunicate-iframe-height"); |
24 | | - KommunicateGlobal.document.getElementById('km-chat-widget-close-button').addEventListener('click',function(){ |
25 | | - var closeButtonClick = parent.document.getElementById("kommunicate-widget-iframe"); |
26 | | - closeButtonClick.classList.add("change-kommunicate-iframe-height"); |
27 | | - }); |
28 | | - } |
29 | | - }; |
30 | | - var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; |
31 | | - s.src = "https://widget.kommunicate.io/v2/kommunicate.app"; |
32 | | - var h = document.getElementsByTagName("head")[0]; h.appendChild(s); |
33 | | - window.kommunicate = m; m._globals = kommunicateSettings; |
| 21 | + (function (d, m) { |
| 22 | + var kommunicateSettings = |
| 23 | + { "appId": "App-Id", "popupWidget": true, "containerId": "widget-container","automaticChatOpenOnNavigation": true }; |
| 24 | + var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; |
| 25 | + s.src = "https://widget.kommunicate.io/kommunicate-widget-3.0.min.js"; |
| 26 | + var h = document.getElementsByTagName("head")[0]; h.appendChild(s); |
| 27 | + window.kommunicate = m; m._globals = kommunicateSettings; |
34 | 28 | })(document, window.kommunicate || {}); |
| 29 | + /* NOTE : Use web server to view HTML files as real-time update will not work if you directly open the HTML file in the browser. */ |
35 | 30 | </script> |
36 | 31 | </body> |
| 32 | + |
37 | 33 | </html> |
0 commit comments