views:

166

answers:

1

I have created a greasemonkey script for a website. What the script does is adding a div at the end of the page.

document.body.insertBefore(myDiv, document.body.firstChild);

But now the site adds an iframe for google-ads, as a result my div appears in the iframe too, which is not what i want.
How can i avoid the script to affect iframes.
Any help would be appreciated.

+4  A: 

I put this at the top of my scripts to avoid running on frames or iframes:

if (window.top != window.self)  //don't run on frames or iframes
    return;
npdoty
That's it! THANKS :-)
fwoncn