简体   繁体   English

引号后面的引号中出现字母

[英]letter in quotes appearing just after body tag

We've just launched our new Magento site and the letter 'c' is appearing in quotes immediately after the tag. 我们刚刚启动了新的Magento网站,并且在标记之后的引号中出现了字母“ c”。 It's not showing up before on my local machine or on our QA site, I've checked the template files and it is not there either. 在本地计算机上或我们的质量检查站点上,它没有显示过,我已经检查了模板文件,它也不存在。 I'm almost certain it can not be a code issue as we have the same code running locally and on our QA site under version control with GIT. 我几乎可以肯定这不是代码问题,因为我们在本地和QA站点上使用GIT在版本控制下运行了相同的代码。

We've cleared the cache and I've tried checking to see if JavaScript was inserting it with the chrome dev tools but could find nothing. 我们已经清除了缓存,并尝试检查JavaScript是否使用chrome dev工具将其插入,但找不到任何内容。

Strangely, the 'c' is not in the view source document but I can see it with the chrome inspector. 奇怪的是,“ c”不在视图源文档中,但是我可以通过chrome inspector看到它。

在此处输入图片说明

I also don't think it can be coming from Magento CMS Pages/Blocks as it loading immediately after the tag. 我也不认为它可能来自Magento CMS页面/块,因为它在标记之后立即加载。

thanks for the link. 感谢您的链接。 after reviewing the page source, you have an extra c character in the header area: 查看页面源代码后,标题区域中将包含一个额外的c字符:

    <!-- END GOOGLE ANALYTICS CODE -->
c<script type="text/javascript">//<![CDATA[
        var Translator = new Translate([]);
        //]]></script>

Notice that c before the script tag? 注意脚本标记之前的c吗?

Just in support to Benny Lin's very helpful answer. 仅出于对本尼·林非常有用的回答的支持。

What was happening was we had our Google Analytics code loading from a template file which contained the stray letter 'c'. 发生了什么事,我们从包含迷路字母“ c”的模板文件加载了Google Analytics(分析)代码。 We could see this on our local machines as this templates was disabled in the Magento admin settings, but not on production. 我们可以在本地计算机上看到此信息,因为此模板在Magento管理员设置中已禁用,但在生产环境中未启用。

This issue seems to demonstrate that when a stray letter appears within the <body> tags on your dev tools inspector and not the view source page it may be because it is in the <head> section. 这个问题似乎表明,当杂散字母出现在开发工具检查器的<body>标记中而不是查看源页面中时,可能是因为它在<head>部分中。 The browser seems to push all poorly formatted html from the <head> section into the <body> section when rendering. 呈现时,浏览器似乎会将<head>部分中所有格式不正确的html推送到<body>部分中。

For example if you open the below html in the chrome browser you will see what I mean: 例如,如果您在chrome浏览器中打开以下html,您将会明白我的意思:

<!DOCTYPE html>
<html>
<head>
c<title>Title of the document in head</title>
<script type="text/javascript">
  var test = "test";
</script>
</head>

<body>
The body of the document......
</body>

</html>

Also while we were searching for the stray letter, we were ably to remove it with the below JavaScript that targets the offending XML node in the DOM with an XPath expression and removes that node only. 同样,当我们在寻找流浪字母时,我们可以使用下面的JavaScript来删除它,该JavaScript使用XPath表达式针对DOM中有问题的XML节点,并且仅删除该节点。

<script type="text/javascript">
  function _x(STR_XPATH) {
      var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
      var xnodes = [];
      var xres;
      while (xres = xresult.iterateNext()) {
          xnodes.push(xres);
      }    
      return xnodes;
  }
  jQuery(_x('//html/body/text()[contains(.,"c")]')).remove();  
</script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM