Sumit
Sumit

Reputation: 1

javascript to show alert message if find specific text in webpage

I have a webpage named "X" with another webpage in an iframe named "Y". Page "Y" gets updated every half an hour and new information arrives. I want a javascript code to be insterted in page "X" to show an alert box if a particular text string is available in page "Y".

How do I do that?

Upvotes: 0

Views: 284

Answers (1)

Willem D'Haeseleer
Willem D'Haeseleer

Reputation: 20180

This will only work if the page inside the iframe is on the same domain as your parent page. Otherwise your browser will not allow it.

You can access the page inside the iframe with the contentWindow.document member on the iframe object. small exampl

// assuming your iframe has an id of "myframe"
document.getElementById("myframe").contentWindow.document.getElementById("someId")

Upvotes: 2

Related Questions