EVOLUTION-MANAGER
Edit File: getQueryString.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Get the query string / hash component from the URL</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for getQueryString {shiny}"><tr><td>getQueryString {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get the query string / hash component from the URL</h2> <h3>Description</h3> <p>Two user friendly wrappers for getting the query string and the hash component from the app's URL. </p> <h3>Usage</h3> <pre> getQueryString(session = getDefaultReactiveDomain()) getUrlHash(session = getDefaultReactiveDomain()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>session</code></td> <td> <p>A Shiny session object.</p> </td></tr> </table> <h3>Details</h3> <p>These can be particularly useful if you want to display different content depending on the values in the query string / hash (e.g. instead of basing the conditional on an input or a calculated reactive, you can base it on the query string). However, note that, if you're changing the query string / hash programatically from within the server code, you must use <code style="white-space: pre;">updateQueryString(_yourNewQueryString_, mode = "push")</code>. The default <code>mode</code> for <code>updateQueryString</code> is <code>"replace"</code>, which doesn't raise any events, so any observers or reactives that depend on it will <em>not</em> get triggered. However, if you're changing the query string / hash directly by typing directly in the browser and hitting enter, you don't have to worry about this. </p> <h3>Value</h3> <p>For <code>getQueryString</code>, a named list. For example, the query string <code>?param1=value1&param2=value2</code> becomes <code>list(param1 = value1, param2 = value2)</code>. For <code>getUrlHash</code>, a character vector with the hash (including the leading <code style="white-space: pre;">#</code> symbol). </p> <h3>See Also</h3> <p><code><a href="updateQueryString.html">updateQueryString()</a></code> </p> <h3>Examples</h3> <pre> ## Only run this example in interactive R sessions if (interactive()) { ## App 1: getQueryString ## Printing the value of the query string ## (Use the back and forward buttons to see how the browser ## keeps a record of each state) shinyApp( ui = fluidPage( textInput("txt", "Enter new query string"), helpText("Format: ?param1=val1&param2=val2"), actionButton("go", "Update"), hr(), verbatimTextOutput("query") ), server = function(input, output, session) { observeEvent(input$go, { updateQueryString(input$txt, mode = "push") }) output$query <- renderText({ query <- getQueryString() queryText <- paste(names(query), query, sep = "=", collapse=", ") paste("Your query string is:\n", queryText) }) } ) ## App 2: getUrlHash ## Printing the value of the URL hash ## (Use the back and forward buttons to see how the browser ## keeps a record of each state) shinyApp( ui = fluidPage( textInput("txt", "Enter new hash"), helpText("Format: #hash"), actionButton("go", "Update"), hr(), verbatimTextOutput("hash") ), server = function(input, output, session) { observeEvent(input$go, { updateQueryString(input$txt, mode = "push") }) output$hash <- renderText({ hash <- getUrlHash() paste("Your hash is:\n", hash) }) } ) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>