Do you control the source of the iframe? If so, include the Javascript in it originally.
If you’re trying to inject the Javascript into the iframe dynamically, you’ll run up against cross domain security issues. Imagine a hacker creating an iframe that goes to Paypal and injecting their own Javascript into it.
If you can describe what you’re trying to accomplish outside of the technique you’re trying to use to get there, maybe there are alternatives that don’t involve injecting Javascript into the iframe.