0

What I have is an iframe displaying a web page for a sensor that hosts it's own webpage showing humidity and temperature. All I really need is the current temperature and humidity so that I can display it on a main page displaying lab status. So from what I gather I need to reach into the iframe, that way I can get to the tr/td values for the table being used to hold what I need.

From scouring the internet top to bottom I put together the following code...

var myIFrame = document.getElementById('ifOmega');
var content = myIFrame.contentWindow.document.body.innerHTML;

The problem is that the second line silently fails. I tested myIframe to ensure that it executed and was not null. I am using Visual Studios 2010 and so I am not sure if maybe it's a limitation there? I only say that because when I try to type...

var content = myIFrame.

...the intellisense doesn't pop up with contentWindow as an option.

Even when I figure this out I'm not sure how to dig deeper other than.

var var0 = content.getElementById('rd0');

Where rd0 is the name/id of the cell that has a div inside containing the temperature value. I am assuming to reach into the I will need one of the javascript sibling/child methods?

BTW, my javascript is executed client side with...

Sys.Application.add_load(getTempTable);

..at the top.

Thank you for any help.

6
  • How about ? stackoverflow.com/questions/1451208/… Commented Jan 20, 2015 at 18:08
  • And stackoverflow.com/questions/19498725/… Commented Jan 20, 2015 at 18:08
  • @Aristos: 1st one I already tried and it also silently failed. 2nd one I didn't come across but that looks promising. EDIT: 2nd one also silently dies. Commented Jan 20, 2015 at 18:10
  • Maybe it being client-side is the problem? Maybe my script is being ran before the external page is being rendered? Therefore 'lb0' doesn't yet exist, but the asp.net control-> iframe does. Commented Jan 20, 2015 at 18:22
  • You have check that the ids are correct ? eg asp.net usually change the ids, and we use the ClientID property to gets them like: getElementById('<%=myIFrameElemId.ClientID%>') Commented Jan 20, 2015 at 18:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.