我有一个小问题。如果客户登录并且具有 url 前缀 https://
,我想更改 IFrame 的 url因此,在登录之前,iframe 的 url 是例如http://www.google.de/pictures/iframe.html 他登录后 iframe 的 url 是 https://www.google.de/pictures/iframe.html
不同之处仅在于“https”
最佳答案
您不需要 JavaScript 来执行此操作。您所需要的只是 HTML:
<iframe src="//www.google.de/pictures/iframe.html" id="ifrm1">
看看我是如何省略 http:
或 https:
部分的吗?那是scheme-relative URL .
使用此代码,iframe
将使用 http:
或 https:
,具体取决于外部文档使用的方案/协议(protocol)。
关于JQuery:如果我从 http://更改为 https://,如何更改 iframe 的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6757727/