You're getting 2 errors here. The first one is a cross-domain problem, and you won't be able to fix that. It is impossible for your site to access the loaded iframe's site at all. Otherwise, the browser would be really insecure, allowing one site to very easily get the user's settings on another site by just loading an iframe. So, you can't change anything within the iframe. The only thing you can do to the iframe's contents is iframeElement.src = '//otherurl.com';
- changing the source url of the iframe.
To fix the second problem, you can do the following: Instead of using http://
or https://
in the url you're defining in your scripts or forms, you can just use //
. That will automatically 'fill in' the same protocol as the one you're using now. So, if you're on http://
at the moment, it'll load the iframe in http://
too, and vice versa.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…