【问题标题】:Force an IFrame to load the mobile version of a website强制 IFrame 加载网站的移动版本
【发布时间】:2021-11-21 11:50:57
【问题描述】:

我需要在我正在构建的网页的 iFrame 中加载网站的移动版本, 网址是这个

https://m.calcionapoli24.it/diretta/spalletti-napoli-spartak-mosca-conferenza-n495703.html

但是会自动重定向到桌面版本的 URL

https://www.calcionapoli24.it/diretta/spalletti-napoli-spartak-mosca-conferenza-n495703.html

如何避免重定向?如何强制 IFrame 加载移动版本?

更改用户代理? PHP 卷曲? Javascript AJAX?

代码很基础

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        iframe {
    width: 750px;
    max-width: 750px;
    height: 1334px;
    margin: 0 auto;
    border-style: none;
    border-color: inherit;
    border-width: 0px;
    display: block;
        }
    </style>
</head>
<body>
    <div> 
        <iframe src="https://m.calcionapoli24.it/diretta/spalletti-napoli-spartak-mosca-conferenza-n495703.html"></iframe>
     </div>
</body>
</html>

【问题讨论】:

    标签: javascript php html iframe user-agent


    【解决方案1】:

    您可以在 url ex ?from_frame=1 中添加查询参数

    然后从 .htaccess 文件中捕获此规则,并将 .htaccess 内部重定向到网站的移动版本

    【讨论】:

    • Agamemnon 我不明白 .htaccess 文件会以何种方式影响 i
    • 您应该找到问题重定向发生的级别
    • 当我将 src 属性设置为 Iframe 时,IFrame 本身会显示该外部页面 URL 的桌面版本
    • 从 m 重定向的位置和原因。 www 发生了什么?
    • 我已经在我的问题中添加了代码,它在 IFrame 的 src 属性中非常基本,当我在 IFrame 中看到 Chrome 上的 HTML 页面时,它有该外部页面的移动版本的 URL显示桌面版本的 URL(不带 m。)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2019-03-18
    相关资源
    最近更新 更多