The frame requesting access has a protocol of “https”, the frame being accessed has a protocol of “http”. Protocols must match

前端 未结 2 486
星月不相逢
星月不相逢 2020-12-10 14:02

I\'m getting this error :

Uncaught SecurityError: Blocked a frame with origin \"https://lss-servicedesk.techteam.com\" from accessing a frame with origin \"http://m

2条回答
  •  离开以前
    2020-12-10 14:48

    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.

提交回复
热议问题