如何将PHP页面添加到blogspot.com新页面

时间:2019-05-20 10:02:27

标签: javascript php blogger

我有一个像http://hiteachers.com/soccer_parse.php?id=5这样的真实.php页面。我想将其添加到blogger.com新页面中(**不是新的博客文章,也不是新的HTML小部件**,而我已经成功地做到了这一点。

https://tranbongda.blogspot.com/p/function-myfunction-window.html

我使用了这样的代码:

<script> 
  var Window; 
  // Function that open the new Window 
  function windowOpen() { 
      Window = window.open("http://hiteachers.com/soccer_parse.php?id=5", 
                             "_blank", "width=400, height=450"); 
  } 
  // function that Closes the open Window 
      function windowClose() { 
            Window.close(); 
   } 
 </script> 
<button onclick="windowOpen()">Open page</button> 
    <button onclick="windowClose()">Close page</button> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
  $(document).ready(function()
  $("button").click(function(){
    $("#div1").load("http://hiteachers.com/soccer_parse.php?id=5");
  });
});
</script>

我的期望是,我希望blogger page在访问者访问blogger.com页面(.php page)时立即加载https://tranbongda.blogspot.com/p/function-myfunction-window.html的原始内容,而无需单击任何按钮。

我已经考虑过通过以下方式创建iframe:

<iframe name="Framename" src="http://hiteachers.com/soccer_parse.php?id=5" width="550" height="550" frameborder="0" scrolling="yes" style="width: 100%;"> </iframe>

但是blogger.com页面不接受它,并返回如下错误消息: This page contains HTTP resources which may cause mixed content affecting security and user experience if blog is viewed over HTTPS.

然后,我按照一些博客的建议尝试使用<object width="500" height="300" type="text/html" data="http://hiteachers.com/soccer_parse.php?id=5"></object>,但是我还是失败了。

其他一些博客作者建议使用AJAX,这对我来说是很新的。

因此,有什么方法可以解析provided .php page content并将其添加到blogspot.com/blogger.com new page而不显示.php页面或窗口弹出窗口的网址?

你能帮我吗?

谢谢

1 个答案:

答案 0 :(得分:0)

正如博客作者可能建议的那样,将PHP服务器作为REST端点,并使用异步JavaScript和XML访问博客站点上的数据。尽管今天人们倾向于刮擦XML部分并使用JSON之类的东西。 AJAX通过使用XMLHttpRequest对象来完成。 Mozilla's spec提供的链接和内容将show you how to use it w3schools是很好的资源。

这就是直接编辑页面的全部

element.removeChild(element.lastChild);
element.appendAdjacentHTML('beforeend',xhr.responseText);
相关问题