javascript - 如何隐藏机器人窗口/iframe

标签 javascript jquery html css botframework

我的团队目前在 Microsoft Bot Framework 元素中工作。我们正在展示机器人:

<iframe src="https://webchat.botframework.com/embed/YOUR_BOT_ID?s=YOUR_SECRET_HERE"></iframe>

我们的客户询问有关显示/隐藏机器人 iframe 的问题,是否可以使用 iframe 来实现?我正在尝试 $('#iFrameId').hidden = !$('#iFrameId').hidden 之类的示例代码在 iframe 的点击事件中,但它不起作用。

谢谢

最佳答案

是的,您可以隐藏 iframe。

例如:

function hideShow() {
  let frame = document.getElementById("f");
  frame.style.visibility = frame.style.visibility == "visible" ? "hidden" : "visible";
}
<iframe id="f" src="https://wikipedia.org" style="visibility: visible;"></iframe>
<button onclick="hideShow();">Hide/Show</button>

更新:(我的评论中的解决方案 2)单击 iframe 的边框以隐藏 iframe。

let frame = document.getElementById("f");

function hideShow() {
  frame.height = frame.height == "0px" ? "150px" : "0px";
}

frame.addEventListener("click", hideShow);
#f {
  border-top: #0c0 20px solid;
}
<iframe id="f" src="https://wikipedia.org" height="150px"></iframe>

关于javascript - 如何隐藏机器人窗口/iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48714599/

相关文章:

jquery - HTML5 localStorage 作为改变 CSS 的条件工具

javascript - 图像和文本对齐、页脚和文本问题

javascript - 如何从生成的 JSON 数组中提取 JSON 对象?

javascript - for 循环中的条件行为不当

javascript - 由于范围问题,ng-click 不会在 ng-repeat 内触发

javascript - 检查.push之前数组中是否存在数据

jquery - 使用 JQuery $.get 确定返回值?

javascript - 在谷歌地图API中自定义自动完成字段

javascript - 如何将值传递给 angularjs 指令?

javascript - 尝试在 div 中引用没有 id 的 header