mootools
The administrative control panel I build for my customers features FCKEditor, a powerful WYSIWYG editor that allows the customer to add links, bold text, create ordered lists, and so on. I provide training and documentation to the customers but many times they simply forget to include the "http://" when add links into their content. Essentially, they end up with links that look like:
我为客户构建的管理控制面板具有FCKEditor,这是一个功能强大的WYSIWYG编辑器,允许客户添加链接,粗体文本,创建有序列表等。 我为客户提供培训和文档,但是很多时候,他们在将链接添加到他们的内容中时忘记了添加“ http://”。 本质上,它们最终具有如下链接:
<a href="www.davidwalsh.name">Click here</a>
Obviously, that's a problem. Luckily MooTools 1.2 provides a quick fix for that problem for website users.
显然,这是一个问题。 幸运的是,MooTools 1.2为网站用户提供了针对该问题的快速修复。
MooTools 1.2代码 (The MooTools 1.2 Code)
window.addEvent('domready', function() {
$('fix-links').addEvent('click', function() {
$$('a[href^=www.]').each(function(el) {
el.set('href','http://www.' + el.get('href').split('www.')[1]);
});
alert('Links fixed.');
});
});
The above solutions is NOT the best solution because it doesn't correct what the search engines see. Have a PHP solution? Submit it! The best solution is to fix the link within the FCKEditor plugin at the time the user adds the link. The code above, however, will buy you a little time to go in and fix any existing errant links.
上述解决方案不是最佳解决方案,因为它无法纠正搜索引擎看到的内容。 有PHP解决方案吗? 提交! 最好的解决方案是在用户添加链接时在FCKEditor插件中修复该链接。 但是,上面的代码将使您花费一些时间来修复所有现有的错误链接。
mootools