【问题标题】:loading other domain page in my app在我的应用程序中加载其他域页面
【发布时间】:2014-07-06 19:25:44
【问题描述】:

jquery 移动应用,如何加载其他域网页

我尝试了 iFrame,但遇到了手机尺寸问题

我尝试了 PHP file_get_contents 页面加载,但内部链接/脚本不起作用

有什么想法吗??

谢谢

这是我的代码

HTML:

<div data-role="header">
    <a href="#home" data-role="button"  data-inline="true" data-icon="home" >home</a>
    <h1>lists</h1>
</div>
<div data-role="content">
    <div id="listDetail" style="height:100%;width:100%">
    </div>
</div>

JS

    var list_url= 'http://lists.php';
    $.ajax({          
        type:  'GET',
        data: {area: areaID },
        url:   list_url,
        dataType: 'html',              
        success: function(result){
            $("#listDetail").html(result);
        }
     });

PHP

    echo file_get_contents("http://m.booking.com/searchresults.html?aid=123456&lang=en&lang=en&latitude=55&longitude=56&radius=40");

【问题讨论】:

    标签: php jquery ajax jquery-mobile


    【解决方案1】:

    链接标签“a”可能包含这样的url href="/searchresult....." 你可以像这样替换全部或附加所有链接

    $content = file_get_contents("http://m.booking.com/searchresults.html?aid=123456&lang=en&lang=en&latitude=55&longitude=56&radius=40");
    $content = str_replace ('href="/','href="http://m.booking.com/"',$content);
    echo $content;
    

    同样查看所有链接并使其正确路径

    【讨论】:

    • 我收到此错误:资源解释为样式表,但使用 MIME 类型 text/html 传输:“m.booking.com”。
    • 样式表的标签也有 href 属性,现在您不需要替换样式表的 href .. 再次尝试代码
    • 我收到以下错误:“Uncaught SecurityError: Blocked a frame with origin "4228414.fls.doubleclick.net" from access a frame with origin "m.booking.com". 协议、域和端口必须匹配。”
    猜你喜欢
    • 2021-02-13
    • 2011-10-17
    • 2012-12-07
    • 2013-07-29
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多