【问题标题】:Loading external webpage into my page without redirecting to different URL将外部网页加载到我的页面中而不重定向到不同的 URL
【发布时间】:2013-03-29 18:29:23
【问题描述】:

所以我想做的是在我的网站上创建一个子域,然后让它加载一个外部网站,而不是真正去那个网站。例如:

google.mydomain.com 加载 google.com,但 URL 栏显示为 google.mydomain.com。

我该怎么做?

我尝试了this,但无法弄清楚。

尝试:

iframe

  1. 我希望页面占据每个人计算机的整个屏幕。我可以将其设置为 100% 而不是 x 像素吗?

  2. 我想删除滚动条,但显示不支持。

【问题讨论】:

    标签: php html redirect iframe external


    【解决方案1】:

    您将无法使用 php 的 include 函数,因为这不是驻留在您服务器上的资源。

    您可以探索的一个选项是将所有内容作为 iframe 的内容加载:有关 iframe html 元素的一些详细信息,请参阅 http://www.w3schools.com/tags/tag_iframe.asp

    【讨论】:

      【解决方案2】:

      您可以使用 iframe 或 file_get_contents();

      内嵌框架:

      <iframe src="http://google.com" style="width: 100%; height: 100%;">
      

      file_get_contents():

      <?php
      echo file_get_contents('http://google.com');
      ?>
      

      使用 file_get_contents(),您需要注意使用相对 URL 获取的网站,这会破坏 CSS、图像、Javascript 等。

      【讨论】:

      • 绝对完美,谢谢!如果可能的话,只需要移除卷轴,但几乎不会引起注意。
      • 好!在 iframe 上,您可以使用类似 scrolling="no" 的内容或在 CSS 中嵌入一些内容,例如 iframe { overflow: hidden; }
      【解决方案3】:
      • 现在 html5 不支持 iframe
      • 它也适用于 html5
      • 易于添加或删除

      例子:

       <body onload="window.location.href='https://www.google.com/'"> </body>
      

      【讨论】:

      • 如何在 wordpress 页面中执行此操作?
      • 我查过了。 HTML5 仍然支持
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-24
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      相关资源
      最近更新 更多