[問題] Shiny 使用javascript抓螢幕解析度

看板R_Language作者 (M)時間10年前 (2015/10/20 17:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
[問題類型]:程式諮詢 [軟體熟悉度]:入門 [問題敘述]: 想要找出使用者目前的解析度, 因此使用 JavaScript 的 window.screen.width , 想將他傳進 Shiny 中變成一個MonitorWidth 變數, 看了以下的參考連結,使用 Shiny.onInputChange 函數, 會一直在 renderPrint 傳出 NULL的結果。 http://tinyurl.com/ptsgpsq [程式範例]: shinyUI( bootstrapPage( tags$script(' var Width = window.screen.width; Shiny.onInputChange("MonitorWidth", Width); ') ,verbatimTextOutput("results") )) shinyServer(function(input, output, session) { output$results = renderPrint({ input$MonitorWidth }) }) [環境敘述]: [關鍵字]:Shiny JavaScript -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.63.0 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1445334133.A.950.html
文章代碼(AID): #1M9WnrbG (R_Language)
文章代碼(AID): #1M9WnrbG (R_Language)