mwdar
mwdar

Reputation: 1

How to find a specific word in Iframe page using javascript?

How to find a specific word in an iframe page?

I don't have control over the iframe page so all codes must be placed in teh parent page.

This is a code to find a word in the parent page

init();

function init()
{
    searchWord("exgirlfriend");  
}

function searchWord(word)
{
   var pageResults = document.body.innerHTML.match(word);  
   if(pageResults)
   {
       alert("word found");    
   }
}

Upvotes: 0

Views: 607

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

You cannot access the content of an iframe that comes from another domain because of the same origin policy.

Upvotes: 3

Related Questions