html - 从外部第三方网页嵌入 <div>

标签 html css

我试图在我的网页中显示一个包含文本框和按钮的 div。

div 不在我的服务器中,是第三方网站,我无权修改基本代码。

这是可能的???这是我想在我的网站上显示的代码,来自第三方网站。

div标签id是“body”

<div id="body"> 
        <h2>Consulta de Teléfonos Robados o Bloqueados por IMEI</h2><div style="width:100%; height:auto;">
<script type="text/javascript">
function buscar(keyWords){
jQuery(document).ready(function($){
    $.post('../../../bdtronline/sistema/areas.php',{
    accion:'searchImei',
    keyWords:keyWords},
    function(data){$('#listImeiFound').html(data);});
});
}
</script>
<form>
Buscar <input type="text" id="keyWords" name="keyWords" size="50" /><input type="button" value="buscar" onclick="buscar(document.getElementById('keyWords').value);"     />
</form>
</body>

最佳答案

如果在运行 JavaScript 的服务器上运行 PHP,则可以加载服​​务器页面,通过 PHP 从其他域获取页面内容:

proxy.php:

<?php
$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => "Content-Type: application/x-www-form-urlencoded",
    'content' => http_build_query($_POST)
  )
);
$context = stream_context_create($opts);
echo file_get_contents('http://php.net/manual/en/function.file-get-contents.php', false, $context);

yoursite.html

// ...
jQuery(document).ready(function($){
    $.post('proxy.php',{
      accion:'searchImei',
      keyWords:keyWords},
      function(data){$('#listImeiFound').html(data);});
    });
});
// ...

关于html - 从外部第三方网页嵌入 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24829822/

相关文章:

html - 如何使用 Bootstrap 3.0 在移动视口(viewport)上居中 "btn-group btn-group-justified"

css - Safari 不呈现模态窗口

html - Angular 中带有 *ngfor 的右浮动按钮

html - 框上的跨浏览器阴影

javascript - 制作一个表单来单击颜色并发送 html 中的值

html - ReactJS 的样式问题

html - 使用@font-face 呈现 Gill Sans 字体系列

javascript - 使用纯 JS(无 jquery)查找带有类的特定 div

javascript - AMP 下拉错误 : 'onchange' may not appear in tag 'select'

javascript - 使用 postMessage 抓取父页面 css