marius
marius

Reputation: 329

Find string in iframe within parent page

How to trigger function if string found in iframe within parent page ?

I need to alter this to work with string and not element ID:

if (window.frames[0].document.getElementById('mystring'))
{
document.getElementById('Search').style.display = 'block';}  

Upvotes: 0

Views: 1108

Answers (1)

Stefan Steiger
Stefan Steiger

Reputation: 82266

var source = window.frames[0].document.getElementsByTagName('html')[0].innerHTML;
var found = source.search("searchString");

you can also use source.indexOf("searchstring") != -1

Upvotes: 1

Related Questions