2

I'm having trouble accessing an iframe in order to manipulate content inside of the frame.

<iframe id="verify" src="http://www.wesite.com/"></iframe>

When I want to access it, with js, it tells me it's undefined

var frame = document.getElementById("verify");

If that were to work, how would I then access the stuff in that frame to manip it? Would it just be:

frame.document.getElementById("ElementInsideIframe").InnerHtml="etc";

2 Answers2

0

this will work check it:

  if ( frame.contentDocument ) {
    doc = objHTML.contentDocument;
  } else {
    doc = objHTML.contentWindow.document;
  }    
   doc .getElementById("ElementInsideIframe").InnerHtml="etc";

note: for cross domains this kind of JS will not work...

Sanju2014
  • 46
  • 4
0

You can use as below:

var temp = document.getElementsByTagName("iframe");
 var innerDoc = temp[0].contentDocument || temp[0].contentWindow.document;

 innerDoc.getElementById("ElementInsideIframe").innerHTML="Your Text";
Butani Vijay
  • 4,181
  • 2
  • 29
  • 61