[問題] Shiny 使用javascript抓螢幕解析度
[問題類型]:程式諮詢
[軟體熟悉度]:入門
[問題敘述]:
想要找出使用者目前的解析度,
因此使用 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
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章