tbodt / greasekit

Automatically exported from code.google.com/p/greasekit
MIT License
0 stars 0 forks source link

if(top != self) return; trick doesn't stop script from running in embedded iframes #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. make a script like "if(top!=self) return; alert('hi');"
2. visit any web page with an iframe (eg nytimes)

What is the expected output? What do you see instead?

expect just one 'hi'.  you get more than one.

What version of the product are you using? On what operating system?

10.5.6, greasekit 1.5

Please provide any additional information below.

it works in greasemonkey/firefox and is the recommended approach.  would be 
interested in any 
work-arounds you know of.

Original issue reported on code.google.com by sfarr...@gmail.com on 19 Mar 2009 at 4:49

GoogleCodeExporter commented 9 years ago
The real issue seems to be where it runs.  When an iframe loads, the script 
runs, but
`window` refers to the outer window, not the iframe's contentWindow.  The script

console.log(window.location.href);

will verify this.

Original comment by peter.a....@gmail.com on 1 Jun 2009 at 9:50