作者swedrf0112 (M)
看板R_Language
标题[问题] Shiny 使用javascript抓萤幕解析度
时间Tue Oct 20 17:42:09 2015
[问题类型]:程式谘询
[软体熟悉度]:入门
[问题叙述]:
想要找出使用者目前的解析度,
因此使用 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://webptt.com/cn.aspx?n=bbs/R_Language/M.1445334133.A.950.html