You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为Azure聊天机器人实现带右下角开关按钮的可视化嵌入容器

实现右下角可开关的Azure Bot聊天面板

下面是直接可用的嵌入代码,你只需要替换其中的Azure Bot iframe地址即可:

<!DOCTYPE html>
<html>
<head>
    <style>
        /* 聊天面板容器样式 */
        .chat-container {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 1000;
        }

        /* 开关按钮样式 */
        .chat-toggle-btn {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background-color: #0078d4; /* Azure主题色,可自行修改 */
            color: white;
            border: none;
            cursor: pointer;
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            font-size: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .chat-toggle-btn:hover {
            background-color: #005a9e;
        }

        /* 聊天窗口iframe容器,默认隐藏 */
        .chat-window {
            display: none;
            width: 350px;
            height: 500px;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            margin-bottom: 10px;
        }

        .chat-window iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
    </style>
</head>
<body>
    <div class="chat-container">
        <!-- 聊天窗口容器 -->
        <div class="chat-window" id="chatWindow">
            <!-- 替换成你的Azure Bot iframe地址 -->
            <iframe src='https://...s=SECRET_KEY'></iframe>
        </div>
        <!-- 开关按钮 -->
        <button class="chat-toggle-btn" id="chatToggleBtn">💬</button>
    </div>

    <script>
        // 获取元素
        const toggleBtn = document.getElementById('chatToggleBtn');
        const chatWindow = document.getElementById('chatWindow');

        // 点击按钮切换聊天窗口显示/隐藏
        toggleBtn.addEventListener('click', function() {
            if (chatWindow.style.display === 'none') {
                chatWindow.style.display = 'block';
                toggleBtn.textContent = '✕';
            } else {
                chatWindow.style.display = 'none';
                toggleBtn.textContent = '💬';
            }
        });
    </script>
</body>
</html>

使用说明

  • 将代码中的 <iframe src='https://...s=SECRET_KEY'></iframe> 替换为你自己的Azure Bot嵌入iframe代码
  • 可以通过修改CSS中的颜色(background-color)、按钮大小、窗口尺寸等参数,调整样式以匹配你的网站风格
  • 这段代码可以直接嵌入到你的网站页面中,或者保存为单独的HTML文件后集成到现有页面

内容的提问来源于stack exchange,提问作者Luca

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 21:40:41