Spance
Spance

Reputation: 607

Use an iframe of a localhost app

I have a page of my rails app that I would like to use as an iframe on different webpage. The part of my rails app is the new view for my score object. At the moment my rails app is just locally hosted. To test my iframe, I have an HTML page in my public folder of my rails app.

Here is the test.html page

<html>

<iframe width="400" height="400" src="scores/new?site_id=191">

</iframe>

</html>

This isn't working, though. Here is the error I get when I inspect the iframe

GET file:///Users/spencerhanson/Documents/Projects/net-promoter-score/public/scores/new?site_id=191 net::ERR_FILE_NOT_FOUND

I know public/scores/new/.. isn't a place that exists in my project. I can't figure why it's trying to look there. The test.html file is in the /public/ directory. The thing here is, I had this working before, with the same src tag in my iframe. I haven't changed anything, and then one day the iframe just stopped working on my test page. I can't figure out what's going wrong. I know it's probably the src tag of my iframe, since I'm trying to display a site hosted locally on a page that is also local

Upvotes: 9

Views: 38450

Answers (2)

Spance
Spance

Reputation: 607

I figure out that opening the html file as localhost:3000/test.html was the answer, thanks to @absurdhero

Upvotes: 6

Yuvraj Singh Shekhawat
Yuvraj Singh Shekhawat

Reputation: 323

I tried sending full path like:

<iframe src="http://localhost/myfolder/photos-iframe.php?id=2"
  name="thumbnails"
  frameborder="0"
  style="width: 100%;
  height: 150px;">

and its worked for me.

Upvotes: 3

Related Questions