I found another solution without javascript but constructing the parenturl using the session$clientData. Here it is:
library(shiny)
ui <- fluidPage(
titlePanel("Google Groups"),
htmlOutput("iframe")
)
server <- function(input, output, session) {
output$iframe <- renderUI({
parenturl <- paste0(session$clientData$url_protocol,
"//",session$clientData$url_hostname,
":",session$clientData$url_port,
session$clientData$url_pathname)
src = paste0('https://groups.google.com/forum/embed/?place=forum/shiny-discuss',
'&showsearch=true&showpopout=true&parenturl=',parenturl)
cat("src = ",src,"\n")
tags$iframe(id="forum_embed", src=src, height=600, width='100%', frameborder='no')
})
}
shinyApp(ui, server)