2017-01-29 10 views
0

私は、光沢のあるウェブアプリケーションファイルに対して非常に簡単なパスワード保護をしようとしています。下記のコードはindex.htmlに含まれています。同じフォルダ内に "testflex.html"という名前のファイルがあります。それは私がパスワードで保護したいファイルです。ユーザー名とパスワードを入力しても何も起こりません。ただし、WRONG usernameまたはpasswordを入力すると、エラーメッセージが表示されます。R光沢のあるhtmlファイルをjavascript経由で呼び出す方法はありますか?

ヒント

function showPass(form){ 

     var user = form.username.value; 
     var pass = form.pwd.value; 

     var user1 = "admin" // this is the username 
     var pass1 = "abcd1234" // this is the password 

     if(user === user1 && pass === pass1){ 

      window.open = "testflex.html"; 

     } 

     else{ 
      document.write("Wrong password or username"); 
     } 
    } 
</script> 

<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> 
+1

アドオンを。 === –

+0

の代わりにuser1、pass1の後に==を使用しようとしていますが、コードに間違いがいくつかありますが、それでも解決策は機能しません...とにかくThxです。 –

答えて

1

面白いアイデア(コードは以下の通りです)。 使用window.open("testflex.html")代わりのwindow.open = "testflex.html"; これが私の作品:あなたの質問に関しては

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) 
+0

ありがとうございます。私は光沢のあるアプリケーションのスクリプト自体の中からこれを処理できるはずです。私が家から帰ると、今夜それを見るだろう。 –

+0

あなたのために働きますか? – BigDataScientist

+0

実際にはそうではありません...ブラウザは、ジャースクリプトがサーバ上の他のファイルを開くことができると受け入れません... –

関連する問題