-2

Hi guys i want to check if DIV test exists in iframe show alert"

 <html>
  <body>
   <div id="test">test</div>
  </body>
</html>

I loaded this html file to my iframe. How can i check if DIV test exists ?

<iframe src="1.html" width="80%" height="600" id="frameDemo"></iframe>
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Danny
  • 11
  • 1
  • 4

1 Answers1

1
var iframe = document.getElementById('frameDemo');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var test = innerDoc.getElementById('test');

if(test != undefined) {

    alert('Exists');

}else{

    alert('Do no Exists');
}

:)

Tiger
  • 404
  • 1
  • 4
  • 13