我创建了一个 Microsoft Bot,并希望将其部署在我的网站上。您如何将聊天机器人固定/固定到网站上的某个位置,即使您浏览不同的页面,它也会保持可见。我正在使用 iFrame 进行网络聊天,并希望在网站的右下角显示聊天。之前我正在测试机器人,所以我在网站上创建了一个示例页面并将可折叠的 iFrame 放在那里。这是我正在使用的代码:
<div id="bot" />
<Script>
(function () {
var div = document.createElement("div");
document.getElementsByTagName('body')[0].appendChild(div);
div.outerHTML = "<div id='botDiv' style='height: 38px; position: fixed;
right: 0; bottom: 0; z-index: 1000; background-color: #fff'><div
id='botTitleBar' style='height: 38px; width: 400px; position:fixed; cursor:
pointer;'></div><iframe width='400px' height='600px'
src='https://webchat.botframework.com/embed/sec key'></iframe></div>";
document.querySelector('body').addEventListener('click', function (e) {
e.target.matches = e.target.matches || e.target.msMatchesSelector;
if (e.target.matches('#botTitleBar')) {
var botDiv = document.querySelector('#botDiv');
botDiv.style.height = botDiv.style.height == '600px' ? '38px' : '600px';
};
});
}());
</script>