【问题标题】:How do I get googlebot to see ajax content如何让 googlebot 查看 ajax 内容
【发布时间】:2012-06-10 07:32:04
【问题描述】:

我能以某种方式轻松让 googlebot 看到这个 ajax 内容吗?使用post ajax方法:

调用页面:

<html>
<head>
<title>TEST</title>
</head>
<body onload="getTest(1)">
<div id="txtHint"></div>        
<script type="text/javascript">
function getTest(page)
{
    var parameters = "";
    document.getElementById("txtHint").innerHTML="";
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
    }
    parameters = parameters + "page="+page;
    xmlhttp.open("POST","ajaxtest.php",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send(parameters);
}
</script>
</body>
</html>

ajaxtest.php:

<?php
    $page=$_POST["page"];
    echo "This is page number $page <br />";
    echo "<a href='javascript:getTest(2);'>Link to page 2</a>"; 
?>

这正是我想要的,它有效。导航是在 ajax 调用中生成的。唯一的问题是 Google 看不到它...

【问题讨论】:

    标签: ajax post googlebot


    【解决方案1】:

    Google explains exactly how to do it。仅供参考,通常使用 Ajax 或 JavaScript 来生成您的内容是 a really bad idea

    【讨论】:

      【解决方案2】:
      <div id="txtHint"><?php include 'ajaxtest.php'; ?></div> 
      

      没有解决您的问题?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-09-09
        • 1970-01-01
        • 1970-01-01
        • 2019-07-13
        • 1970-01-01
        • 1970-01-01
        • 2013-04-08
        • 2012-04-30
        相关资源
        最近更新 更多