r - 如何在闪亮的应用程序中显示外部网站?
问题描述
我正在尝试将 URL 连接到左侧 sidebarMenu 中的 menuSubItem,因此如果单击该项目,它将在右侧空白页面中显示网页。我已经尝试tags$iframe
或简单地放入a(href="")
UI,但都失败了。下面是我在 UI 中的示例代码。
```
sidebar<- dashboardSidebar(
sidebarMenu(id = "tabs",
menuItem("Homepage", tabName = "homepage", icon = icon("home")),
menuItem("Liability Distribution", tabName = "liab_dist",
menuSubItem("Google", tabName = "Google", icon = icon("angle-right")))))
body<-dashboardBody(
tabItems(
#Google
tabItem(tabName = "Google",
fluidRow(
tags$iframe(
seamless = "seamless",
src = "http://google.com",
height = 800, width = 1400)))))
解决方案
您的代码没有任何问题 - 处理 iframe 时只有两个警告:1.) RStudio 不加载外部资源 - 猜测是为了安全。但是一旦你运行你闪亮的应用程序,你就会得到这样的输出:Listening on http://127.0.0.1:7572
. 当您粘贴http:...
到 Chrome(或 Firefox 或您喜欢的浏览器)中的新标签页时,大多数情况下您会得到一些内容。谷歌是一个例外(还有更多),因为 2.)一些网站告诉浏览器不要在 iframe 中显示它们(当你在 Chrome 中打开 devtools 访问 google.com 时(或再次:Firefox 或你最喜欢的) , 你会看到的x-frame-options: SAMEORIGIN
作为响应头。所以你在这里不走运 - 但我建议尝试使用你的个人博客或你知道允许 iFrames 的某些页面。只要你打开除了 RStudio 的 Shiny 预览之外的任何东西,你很可能会得到一个结果。
推荐阅读
- adb - 启用安全 ADB 模式
- python-3.x - python3在文件结束后重置标准输入
- flutter - 在android上重新启动应用程序后显示Flutter hive数据
- xamarin.forms - telerikInput:RadAutoCompleteView 关闭图标颜色变化
- javascript - 管理网站的文件和扩展名
- javascript - 如何使用正则表达式将 HTML 标签包裹在占位符周围?
- python - 如何为多索引熊猫数据框组合重复的标题列?
- jquery - 格式化数据表中的日期列
- python - 即使导入了pk,也没有反向匹配错误
- sql - Entity Framework 6 中的双重上下文使调用变慢?