I've run into a problem: I'm trying to display a widget in my Shiny app. The HTML that I'm trying to embed runs perfectly if I save it and view it. It also runs fine on a HTML viewer. When I insert the HTML into my UI, it doesn't show up. I suspect it is because it contains a <script>
tag.
I've tried wrapping the HTML with tags$div(HTML())
as well as includeScript(path = myhtml.html)
(with and without wrapping the HTML in <body></body>
). Nothing seems to produce results.
Any ideas? Thanks very much.
Here's my HTML:
<a
class="weatherwidget-io"
href="https://forecast7.com/en/40d71n74d01/new-york/"
data-label_1="New York"
data-label_2="Weather"
data-font="Fira Sans"
data-days="3"
data-theme="weather_one"
>My Weather</a
>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://weatherwidget.io/js/widget.min.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weatherwidget-io-js');
</script>
Edit: Here's a sample app doing exactly what I'm trying to: When I run it it's blank.
library(shiny)
ui <- fluidPage(
tags$div(HTML("<a
class=\"weatherwidget-io\"
href=\"https://forecast7.com/en/40d71n74d01/new-york/\"
data-label_1=\"New York\"
data-label_2=\"Weather\"
data-font=\"Fira Sans\"
data-days=\"3\"
data-theme=\"weather_one\"
>Saint George Canadawide Sports HQ</a
>
<script type=\"text/javascript\">
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://weatherwidget.io/js/widget.min.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weatherwidget-io-js');
</script>")))
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)