0

I really need your help. I have an object that contains an iframe's content - Output of Chrome Dev Tools Console ( Sorry couldn't upload a inline screenshot of the code ).

I want to know how can I search programmatically if the text string "Welcome" exists in this object - it possible to navigate with Chrome Dev Tools to the element containing the text.

I have tried doing something as follows

var html = $("#HTML")[0]; // also tried $("#HTML").contents()
var iframeObj = JSON.stringify(html);
if(iframeObj.indexOf('Welcome') > -1)
{
  alert('match found')
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

but this JSON.stringify(html) unfortunately exclude the content of the iframe in the resulting string. I also played around with Jquery's contents() to get the contents specifically of the iframe but to no avail.

Would appreciate your help

Yannick Huber
  • 619
  • 2
  • 21
  • 35
  • 1
    Possible duplicate of [jQuery/JavaScript: accessing contents of an iframe](http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – c69 Mar 01 '17 at 08:48
  • I will have a look at this - thx – hannocoetzer Mar 01 '17 at 08:49
  • Nope .. I just don't get any useful data. I tried $("#HTML").contents().find('body') .. it returns a empty array object .. It is on the same domain – hannocoetzer Mar 01 '17 at 08:57
  • 1
    Your snippet is unuseful. I can't see on your code an element with `id="HTML"` and I can't see on your code where `iframeObj` is declared and how. Just edit your question with the relevant code and try again – Marcos Pérez Gude Mar 01 '17 at 10:53

0 Answers0