【问题标题】:Googlebots causes JS errors, should I care?Googlebots 会导致 JS 错误,我应该在意吗?
【发布时间】:2015-07-08 11:48:28
【问题描述】:

在生产服务器上,我观察 JS 错误并发送到服务器:

<script type="text/javascript">
window.onerror=function(msg,url,line) {
    if (window.XMLHttpRequest)
    {
        var xmlhttp = new XMLHttpRequest();
    }
    else
    {
        var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    }
    xmlhttp.open('POST', '/logJSerrorsHere', true);
    xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    xmlhttp.send('msg='+encodeURIComponent(msg)+'&url='+encodeURIComponent(url)+'&line='+line);
    return true;
}</script>

有时它会记录一些“神秘”的错误:“$ 未定义”,但它们都来自“googlebot(at)googlebot.com”或 spiderbot。我应该处理它吗?

【问题讨论】:

    标签: javascript php ajax google-app-engine


    【解决方案1】:

    取决于 :) 如果您的网站在没有 Javascript 的情况下是可读和可索引的(并且您的网站在搜索中可见),我不会太担心它,除非您认为错误表明存在更大的问题。您可以在 Google 网站管理员工具中使用 Fetch and Render 进行测试。

    如果您的网站依赖 Javascript 来呈现页面(例如,它使用 AngularJS),那么可以,修复它。

    【讨论】:

    • 当然可以正常使用。似乎 BOT 不包含外部 .js 东西
    • 那些JS资产是否被robots.txt排除了?如果不允许 googlebot 访问外部页面资产,则不会包含它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    相关资源
    最近更新 更多