显示另一个网页 蛋糕 2.



将另一个网页显示到具有不同域的当前页面中。

我已经在使用iframe和javascript尝试任何解决方案,但仍然没有解决。

但它显示带有标题、导航栏。现在一切都是双倍的。所以,我想从第二页中删除标题和导航栏。

我认为使用来自Ajax调用的JSON响应可以解决所有问题。例如,假设您的主页 A 内部有一个特定的<div>,ajax 调用使用它来填充您的辅助页面 B。

让我们举个例子:

<html>
    <head>[...]</head>
    <body>
        [...]
        <!-- 
        Using CSS you can style your div in order 
        to be "separated" from the main page style
        -->
        <div class="secondary-page"></div>
        [...]
    </body>
</html>

您所需要的只是使用 ajax 创建一个脚本来调用特定的 CakePHP 控制器,该控制器将返回您的"辅助页面"div 所需的 html。

$.ajax({
   url: 'my/controller/url',
   [...],
   onSuccess: function(response) {
       // Response should contain a value with the html
       // In this way you can append it into your secondary-page div
       $('.secondary-page').append(response.pageBHTML);
   }
});

最新更新