Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 530
Spance Avatar asked May 17 '16 14:05

Spance


People also ask

Can I use iframe for any website?

An iframe, short for inline frame, is an HTML element that contains another HTML document within it. The iframe element is specified with the iframe tag. It may be placed anywhere in an HTML document, and thus anywhere on a web page.

Does Google allow iFrames?

You can embed an entire webpage as an iframe in a new Google site. This will allow you to pull in content from other websites and Google tools like Apps Script, Data Studio, and App Maker, saving you the trouble of duplicating and updating that information on your page.

How do I embed an iframe?

To embed an iframe in a content page, select Interactive layout, choose the HTML block and paste the iframe code there. You can adjust the iframe width and height properties. To embed an iframe using the Old (Classic) editor, click on the Embed Media icon and paste the code in the appropriate field.

How do I open an iframe URL?

To navigate URL in iframe with JavaScript, we have to set the src attribute or return the value of src attribute in an iframe element. The src attribute defines the URL of document that can be shown in an iframe. Absolute URL: It points to another website (For example: https://www.geeksforgeeks.org/c-plus-plus/).


1 Answers

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

like image 72
Spance Avatar answered Oct 04 '22 15:10

Spance