更新:错误已解决。任何解释该修复为何有效的人都将获得答案。
如果您突出显示并复制本页第一段中的文本,然后将其粘贴到富文本编辑器(富文本模式下的 Dreamweaver 或 Gmail)中,您将看到某些文本已自动链接。基本上,它可以工作:
http://seox.org/link-building-pro.html --> http://seox.org/lbp/old-pretty.js
我正在尝试构建第二个版本,但在途中的某个地方我破坏了它。如果您对这个新网址执行相同的过程,则 Chrome 中将删除链接前后的间距:
http://seox.org/test.html --> http://seox.org/lbp/lb-core.js
为什么间距在第一个中可以正常工作,但在第二个中却不能正常工作?更重要的是,如何修复第二个,以免它出错?
我之前问过这个问题的一个变体,并得到了一个有用且有趣的答案,但希望这次我问了这个问题的全部细节。上一个问题的答案我很难理解,位于此处: Javascript: Whitespace Characters being Removed in Chrome (but not Firefox)
预先感谢您的宝贵时间!
<小时/>编辑:我已经在这篇文章中添加了赏金,并且非常感谢有关如何修复错误的精确说明(而不是一般建议。
为了更好地说明该错误,我复制了下面的灰色框(来自第二页)。请注意 a 标签前后的间距是如何删除的:
Link Building 2 is an amazing tool that helps your website visitors share your content, with proper attribution. It connects to email, social sharing sites, eCommerce sites, and is the<a href="http://seox.org/test.html#seo">SEO</a>'s best friend. Think of it as the sneeze in the viral marketing metaphor.
<div>
<p id="credit"><br />
Read more about<a href="http://seox.org/test.html">Text Citations</a>by<a href="http://seox.org">seox.org</a></p>
</div>
<小时/>
第二次更新:
我能够通过将以下内容添加到函数 processSel() 的顶部来解决该错误:
lbp.vrs.holder.style.position = "absolute";
如果谁能最好地解释为什么这可以解决 Chrome 中的间距问题,我将授予正确答案。
最佳答案
第 30 行有一个拼写错误。
... by <a href='http://" + lbp.page.domain + "' />" + lbp.defaults.author ...
^ (extra "/" before ">")
关于javascript - 为什么 Chrome 间距在一个 JS 文件中有效,而在另一个 JS 文件中无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2970759/