I want to get screen resolution from JavaScript, stored in the GetScreenWidth
variable on Shiny Server.
I tried the reference:
- Receiving data from .js in server.R shiny
- https://ryouready.wordpress.com/2013/11/20/sending-data-from-client-to-server-and-back-using-shiny/
So I have:
ui.R
shinyUI(
bootstrapPage(
verbatimTextOutput("results")
,tags$script('
var jsWidth = screen.width;
Shiny.onInputChange("GetScreenWidth",jsWidth);
')
)
)
server.R
shinyServer(function(input,output){
output$results=renderPrint({
input$GetScreenWidth
})
})
It will return NULL
by verbatimTextOutput
.
How should I modify the code? Thanks!