【问题标题】:How to open/use a url having non-standard port within an html iframe?如何在 html iframe 中打开/使用具有非标准端口的 url?
【发布时间】:2016-06-06 18:34:56
【问题描述】:

我无法查看来自 <iframe> 元素的 url:http://www.example.com:9999 的网页,其中包含非标准端口 9999。

并且这个 url (http://www.example.com:9999) 可以从浏览器访问。

以下是我正在使用的示例 html 代码:

<html>
<head>
    <title>Iframe test</title>
</head>
<body>
    <div>
        <iframe src="http://www.example.com:9999" frameborder="0" height="100%" width="100%"></iframe>
    </div>
</body>
</html>


但是当我尝试在src 属性&lt;iframe&gt; 中使用具有标准端口(如:80)的 url 时,效果很好

那么有什么方法可以在&lt;iframe&gt;src 属性中使用具有非标准端口的url。

【问题讨论】:

  • 刚刚检查:在浏览器地址栏中输入非标准端口号的url,看到页面了吗?
  • 是的,可以从浏览器访问具有非标准端口的url。

标签: php html iframe


【解决方案1】:

我认为这是由于同源政策,请参阅question

用于主页和 iframe 的端口应该相同。你可以使用window.postMessage来解决这个问题

【讨论】:

    猜你喜欢
    • 2013-06-01
    • 2020-04-09
    • 2020-01-01
    • 2010-09-07
    • 1970-01-01
    • 2011-12-02
    • 2013-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多