How to use/update tags$iframe ?

702 views
Skip to first unread message

João Carlos

unread,
Dec 3, 2013, 9:10:54 AM12/3/13
to shiny-...@googlegroups.com

Hi,

more beginner questions, 

I´m trying to use tags$iframe inside a ui.R and pageWithSidebar style page but I don´t get how to point to the .html correctly 

to read my data into my app I get it pointing to  ".././data/data.csv" which is in the same folder level as my app. So as  my folder app is ap6 I thought I coud get the .htm with something like  ".././ap6/page.htm" , but it does not work.

        tags$iframe(id="iframe1", src=".././ap6/page.htm", style="width: 400px; height: 400px"),

and I  any pointers or examples on how to update the iframe src from the server side would be great.

Thanks

Joao

 

Joe Cheng

unread,
Dec 3, 2013, 11:44:19 AM12/3/13
to João Carlos, shiny-...@googlegroups.com
Keep in mind that the <iframe> is interpreted by the browser, not the server. So when the browser goes to http://localhost:8100/ and you tell it to go up two levels, it has nowhere to go (nor would you want a browser to be able to arbitrarily go poking around your hard drive!).

There are a few different ways I could see tackling this. If the .htm file isn't going to change, the easiest would be to simply copy it into a subdirectory of your app called "www", and do tags$iframe(src="page.htm", ...) [note that no "www" is needed in the src]. If you do need to keep that page where it is, and don't mind that entire directory being accessible over the web, then take a look at ?addResourcePath.


--
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.
For more options, visit https://groups.google.com/groups/opt_out.

João Carlos

unread,
Dec 3, 2013, 12:00:51 PM12/3/13
to shiny-...@googlegroups.com, João Carlos
Thanks a lot for your time Joe, but I did a minimal test here 

shinyUI(
  
 pageWithSidebar(
    # Título da Aplicação
    headerPanel("Test"),
    

    sidebarPanel
    (

    ),
    
    mainPanel
    (
    
      tags$iframe(id="iframe1", src="page2.htm", style="width: 400px; height: 400px")
      
    )
    ) 
 )


and page2.htm was in the same folder as ui.R and server.R

and its simple

<html>
<body>

body  .....

</body>
</html> 

and I got the Not Found too. 

I´m running from RStudio.

Regards

Joao

João Carlos

unread,
Dec 3, 2013, 12:53:29 PM12/3/13
to shiny-...@googlegroups.com, João Carlos
and addResourcePath worked great :)  but only without the last slash in the folders name as already reported in other thread.

Thanks

Joao 

On Tuesday, December 3, 2013 2:44:19 PM UTC-2, Joe Cheng [RStudio] wrote:

Joe Cheng

unread,
Dec 3, 2013, 1:37:13 PM12/3/13
to João Carlos, shiny-...@googlegroups.com
I'm glad addResourcePath worked for you. For the other approach, you need to put the .htm file in a www subdirectory of the app dir, not in the app dir itself.

Patrick Toche

unread,
Dec 3, 2013, 5:16:31 PM12/3/13
to shiny-...@googlegroups.com, João Carlos
yes, I just tested it.

For instance, if I want to store a csv file here:


I must copy it there:

myname@spark:~/ShinyApps/myshinyapp/www/
Reply all
Reply to author
Forward
0 new messages