如何通过javascript调用R闪亮的html文件?
我正在尝试为R闪亮的web应用程序文件提供一个非常简单的密码保护。下面看到的代码包含在index.html中。同一文件夹中有一个名为testflex.html的文件。这是我想用密码保护的文件。当我输入用户名和密码时,不会发生任何事情。但是,当我输入错误的用户名或密码时,会显示错误消息 有什么提示吗?代码如下 好主意。 关于你的问题: 使用window.opentestflex.html代替window.open=testflex.html; 这对我很有用:如何通过javascript调用R闪亮的html文件?,javascript,r,shiny,shiny-server,Javascript,R,Shiny,Shiny Server,我正在尝试为R闪亮的web应用程序文件提供一个非常简单的密码保护。下面看到的代码包含在index.html中。同一文件夹中有一个名为testflex.html的文件。这是我想用密码保护的文件。当我输入用户名和密码时,不会发生任何事情。但是,当我输入错误的用户名或密码时,会显示错误消息 有什么提示吗?代码如下 好主意。 关于你的问题: 使用window.opentestflex.html代替window.open=testflex.html; 这对我很有用: library(shiny) o
library(shiny)
openWindow <- '
Shiny.addCustomMessageHandler("resetValue", function(message) {
window.open("new.html");
});
'
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
tags$head(tags$script(HTML(openWindow))),
selectInput("open", "Class Type:", c(FALSE, TRUE))
),
mainPanel(
textOutput("class")
)
)
))
server <- shinyServer(function(input, output, session) {
global <- reactiveValues(sample = 1:9)
observe({
if(input$open){
session$sendCustomMessage(type = "resetValue", message = "keyVal")
}
})
output$class <- renderText({
print(input$open)
})
})
shinyApp(ui = ui, server = server)
添加在user1之后,pass1并尝试使用==而不是===我发现代码中有几个错误,但无论如何,解决方案都不起作用。。。谢谢。似乎我应该能够从闪亮的应用程序脚本本身处理这个问题。今晚我从家回来的时候会看的。不,事实上它没有。。。浏览器不会接受javescript可以在服务器上打开其他文件…太糟糕了。嗯,另一个想法是尝试通过R:browseURL?Thx。我会试试的。我试着用apache2。我已经设法让apache服务器pasword工作,但无法让R闪亮的应用程序也运行。不,它也不工作。。。想法仍然是受欢迎的。
<body>
<form>
Username: <input type="text" name="username" /> <br />
Password: <input type="password" name="pwd" /> <br />
<input type="button" value="Log In" onclick="showPass(form)" /> </form> </body>
library(shiny)
openWindow <- '
Shiny.addCustomMessageHandler("resetValue", function(message) {
window.open("new.html");
});
'
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
tags$head(tags$script(HTML(openWindow))),
selectInput("open", "Class Type:", c(FALSE, TRUE))
),
mainPanel(
textOutput("class")
)
)
))
server <- shinyServer(function(input, output, session) {
global <- reactiveValues(sample = 1:9)
observe({
if(input$open){
session$sendCustomMessage(type = "resetValue", message = "keyVal")
}
})
output$class <- renderText({
print(input$open)
})
})
shinyApp(ui = ui, server = server)