How to use to use the 'Shiny.addCustomMessageHandler' in other browsers than Mozilla Firefox

231 views
Skip to first unread message

Raik Otto

unread,
Nov 21, 2014, 12:09:48 PM11/21/14
to shiny-...@googlegroups.com
Dear group,

I'm fairly new to the Shiny world and would like to know if the following problem is indeed a known limitation of Shiny Server or if there merely is a mistake in the source code.
Currently I' struggling with the 'Shiny.addCustomMessageHandler' functionality. The problem is, that it works well on the Firefox browser, however it does not work for any other browser I've tried (Safari, IE10,9,8).

The CustomMessageHandler is supposed to hide and show div boxes, e.g. the 'welcome_div' box, see below. This however, does not work on any other browser apart from the Firefox. For testing purposes I've tried to invoke 'alert' javascript messages instead of the 'hide=true' line, which as well worked fine on the Firefox, but not any other browser. Hence the current assumption is, that the problem has something to do with the CustomMessage Handler.

Snipplet ui.r:

shinyUI(
   
    navbarPage(...       
        tabPanel(
        ...
        tags$head(
               singleton(
                   includeScript("www/script.js")
               )
            ),
        )
        ...
       div( id="welcome_div",
             
           style ="margin-top:1%;background:#eee;fontSize:22;opacity:0.8;border-width:1px;border-style:solid;border-radius:10px;",
           htmlOutput("welcome_text")
                   
       ),
...

"script.js":

Shiny.addCustomMessageHandler("jsCode",
                           
    function(message) {
        eval(message.value);
    }
);

Snipplet server.r:

shinyServer(function(input, output, session) {

    ...
    js_string <- sprintf('document.getElementById("welcome_div").hidden=true;')
    session$sendCustomMessage(type='jsCode', list(value = js_string))
    ...
}

Thank you very much for your help

Joe Cheng

unread,
Nov 21, 2014, 1:12:12 PM11/21/14
to Raik Otto, shiny-...@googlegroups.com
Are there any error messages in the JS console for Safari?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/4cdce6e5-fee1-47dd-b678-f27908400e29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages